Django

Code

Ticket #3845 (closed: fixed)

Opened 2 years ago

Last modified 2 years ago

Add db_index to FlatPages 'url' field

Reported by: jesse.lovelace@gmail.com Assigned to: adrian
Milestone: Component: Contrib apps
Version: SVN Keywords:
Cc: dev@simon.net.nz Triage Stage: Ready for checkin
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Currently the FlatPage? model doesn't have an index on 'url', but always uses 'url' for the lookup in contrib.flatpages.views:

f = get_object_or_404(FlatPage, url__exact=url, sites__id__exact=settings.SITE_ID)

I'm not sure how this could hurt in any case since if you only had a few flatpages your index would be small and if you had many it would be crucial.

Attachments

flatpages_models.diff (0.7 kB) - added by Simon G. <dev@simon.net.nz> on 03/27/07 22:04:21.
adds db_index=True to flatpages

Change History

03/27/07 22:04:21 changed by Simon G. <dev@simon.net.nz>

  • attachment flatpages_models.diff added.

adds db_index=True to flatpages

03/27/07 22:07:33 changed by Simon G. <dev@simon.net.nz>

  • cc set to dev@simon.net.nz.
  • needs_better_patch changed.
  • needs_tests changed.
  • needs_docs changed.
  • has_patch set to 1.
  • stage changed from Unreviewed to Ready for checkin.

Well spotted Jesse! Although, looking at that query - shouldn't the index be on (url, sites_id)?

03/27/07 22:33:35 changed by jesse.lovelace@gmail.com

I didn't know you could specify composite keys with django and I don't know enough about how MySQL/Postgre optimize index usage to comment. Thanks for the patch!

03/29/07 06:46:27 changed by russellm

  • status changed from new to closed.
  • resolution set to fixed.

(In [4849]) Fixed #3845 -- Added index to URL attribute of flatpages model.


Add/Change #3845 (Add db_index to FlatPages 'url' field)




Change Properties
Action