Opened 18 years ago

Closed 18 years ago

#3845 closed (fixed)

Add db_index to FlatPages 'url' field

Reported by: jesse.lovelace@… Owned by: Adrian Holovaty
Component: Contrib apps Version: dev
Severity: Keywords:
Cc: dev@… Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

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 (1)

flatpages_models.diff (743 bytes ) - added by Simon G. <dev@…> 18 years ago.
adds db_index=True to flatpages

Download all attachments as: .zip

Change History (4)

by Simon G. <dev@…>, 18 years ago

Attachment: flatpages_models.diff added

adds db_index=True to flatpages

comment:1 by Simon G. <dev@…>, 18 years ago

Cc: dev@… added
Has patch: set
Triage Stage: UnreviewedReady for checkin

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

comment:2 by jesse.lovelace@…, 18 years ago

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!

comment:3 by Russell Keith-Magee, 18 years ago

Resolution: fixed
Status: newclosed

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

Note: See TracTickets for help on using tickets.
Back to Top