Browse files

[1.6.x] Fixed #21986 -- Added some guidelines for database indexes.

Thanks django-issues at for the suggestion.

Backport of c8d61fa from master
  • Loading branch information...
1 parent e764978 commit 8e704b176f30c9c208a45125d8f36319cf1aafa8 Alex de Landgraaf committed with timgraham Feb 23, 2014
Showing with 11 additions and 3 deletions.
  1. +11 −3 docs/topics/db/optimization.txt
14 docs/topics/db/optimization.txt
@@ -36,11 +36,19 @@ Use standard DB optimization techniques
-* 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:
* Appropriate use of field types.

0 comments on commit 8e704b1

Please sign in to comment.