#16895 closed Cleanup/optimization (fixed)
documentation should warn of cost of ordering
Reported by: | Owned by: | Ivan Kolodyazhny | |
---|---|---|---|
Component: | Documentation | Version: | |
Severity: | Normal | Keywords: | afraid-to-commit |
Cc: | Triage Stage: | Accepted | |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In https://docs.djangoproject.com/en/dev/ref/models/options/#ordering it makes no mention of the database cost of ordering, especially for ordering on non-indexed fields, or the implicit joins of chained orderings. (It doesn't even mention that it chains orderings!) https://docs.djangoproject.com/en/dev/ref/models/querysets/#order-by is another location where the cost might be mentioned. It could additionally go in https://docs.djangoproject.com/en/dev/topics/db/optimization/#don-t-retrieve-things-you-don-t-need as a hint for things to look for when optimizing.
Recommend for model options and querysets pages: "Warning: Ordering is not a free operation. Each field you add to the ordering will incur a cost from your database. Each foreign key you add will include all of its default orderings implicitly."
Recommend for optimization page: "==Don't order if you don't care== Ordering is not free; each field added is an operation the database has to perform."
Change History (7)
comment:1 by , 13 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 11 years ago
Keywords: | afraid-to-commit added |
---|
comment:3 by , 11 years ago
Has patch: | set |
---|---|
Owner: | changed from | to
Status: | new → assigned |
Here is pull request with patch https://github.com/django/django/pull/1603
comment:4 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I think the mention in the optimization docs has priority - but there should be some caution about the risk of having too many performance warnings in the API docs