Opened 19 years ago
Closed 19 years ago
#3845 closed (fixed)
Add db_index to FlatPages 'url' field
| Reported by: | 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)
Change History (4)
by , 19 years ago
| Attachment: | flatpages_models.diff added |
|---|
comment:1 by , 19 years ago
| Cc: | added |
|---|---|
| Has patch: | set |
| Triage Stage: | Unreviewed → Ready for checkin |
Well spotted Jesse! Although, looking at that query - shouldn't the index be on (url, sites_id)?
comment:2 by , 19 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 , 19 years ago
| Resolution: | → fixed |
|---|---|
| Status: | new → closed |
adds db_index=True to flatpages