summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex de Landgraaf <alex@maykinmedia.nl>2014-02-23 13:55:25 +0100
committerTim Graham <timograham@gmail.com>2014-03-03 11:16:41 -0500
commitc8d61fa109b5a4dee1eb6f7ae62c1e6ac00c2cab (patch)
treeca4fed892e2ed03b6f8fff5f4f1066b5eb94f32b
parent5a4f1298cf00fe4e2e35d0a3c02281b4c6afe07c (diff)
Fixed #21986 -- Added some guidelines for database indexes.
Thanks django-issues at colons.co for the suggestion.
-rw-r--r--docs/topics/db/optimization.txt14
1 files changed, 11 insertions, 3 deletions
diff --git a/docs/topics/db/optimization.txt b/docs/topics/db/optimization.txt
index 1f8f43b79f..8847663b1b 100644
--- a/docs/topics/db/optimization.txt
+++ b/docs/topics/db/optimization.txt
@@ -36,11 +36,19 @@ Use standard DB optimization techniques
...including:
-* Indexes. This is a number one priority, *after* you have determined from
+* Indexes_. This is a number one priority, *after* you have determined from
profiling what indexes should be added. Use
- :attr:`django.db.models.Field.db_index` or
+ :attr:`Field.db_index <django.db.models.Field.db_index>` or
:attr:`Meta.index_together <django.db.models.Options.index_together>` to add
- these from Django.
+ these from Django. Consider adding indexes to fields that you frequently
+ query using :meth:`~django.db.models.query.QuerySet.filter()`,
+ :meth:`~django.db.models.query.QuerySet.exclude()`,
+ :meth:`~django.db.models.query.QuerySet.order_by()`, etc. as indexes may help
+ to speed up lookups. Note that determining the best indexes is a complex
+ database-dependent topic that will depend on your particular application.
+ The overhead of maintaining an index may outweigh any gains in query speed.
+
+.. _Indexes: http://en.wikipedia.org/wiki/Database_index
* Appropriate use of field types.