diff options
| author | Mads Jensen <mje@inducks.org> | 2017-10-09 18:19:08 +0200 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2017-10-09 12:19:38 -0400 |
| commit | d3e115151eaf1d7ce8d6402563f9ff7dd2a72180 (patch) | |
| tree | 5b125500ddbe0bd9505857e1d367d6bde15d47f5 /docs/ref/contrib | |
| parent | 22bcb8991721cd791e12ea8f4a75d9d9f2af6f89 (diff) | |
[2.0.x] Fixed #28423 -- Expanded docs for indexing contrib.postgres fields.
Backport of 22ff4f81b1859ed7af7999ef479a10b5d31a2164 from master
Diffstat (limited to 'docs/ref/contrib')
| -rw-r--r-- | docs/ref/contrib/postgres/fields.txt | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/docs/ref/contrib/postgres/fields.txt b/docs/ref/contrib/postgres/fields.txt index 464059e4fb..6fee970c50 100644 --- a/docs/ref/contrib/postgres/fields.txt +++ b/docs/ref/contrib/postgres/fields.txt @@ -7,6 +7,18 @@ module. .. currentmodule:: django.contrib.postgres.fields +Indexing these fields +===================== + +:class:`~django.db.models.Index` and :attr:`.Field.db_index` both create a +B-tree index, which isn't particularly helpful when querying complex data types. +Indexes such as :class:`~django.contrib.postgres.indexes.GinIndex` and +:class:`~django.contrib.postgres.indexes.GistIndex` are better suited, though +the index choice is dependent on the queries that you're using. Generally, GiST +may be a good choice for the :ref:`range fields <range-fields>` and +:class:`HStoreField`, and GIN may be helpful for :class:`ArrayField` and +:class:`JSONField`. + ``ArrayField`` ============== @@ -241,14 +253,6 @@ transform do not change. For example:: at the database level and cannot be supported in a logical, consistent fashion by Django. -Indexing ``ArrayField`` ------------------------ - -At present using :attr:`~django.db.models.Field.db_index` will create a -``btree`` index. This does not offer particularly significant help to querying. -A more useful index is a ``GIN`` index, which you should create using a -:class:`~django.db.migrations.operations.RunSQL` operation. - ``CIText`` fields ================= |
