summaryrefslogtreecommitdiff
path: root/docs/ref/contrib/postgres
diff options
context:
space:
mode:
authorHannes Ljungberg <hannes@5monkeys.se>2019-10-10 20:04:17 +0200
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-01-13 11:47:50 +0100
commit83fcfc9ec8610540948815e127101f1206562ead (patch)
treeaca51a61ef2d7397ee170fc74c564d242c441147 /docs/ref/contrib/postgres
parente3ece0144a988bc522c4bd551baecaf2139ce4ed (diff)
Fixed #26167 -- Added support for functional indexes.
Thanks Simon Charette, Mads Jensen, and Mariusz Felisiak for reviews. Co-authored-by: Markus Holtermann <info@markusholtermann.eu>
Diffstat (limited to 'docs/ref/contrib/postgres')
-rw-r--r--docs/ref/contrib/postgres/indexes.txt70
1 files changed, 63 insertions, 7 deletions
diff --git a/docs/ref/contrib/postgres/indexes.txt b/docs/ref/contrib/postgres/indexes.txt
index f9c0fb2f97..4a9b2ad22e 100644
--- a/docs/ref/contrib/postgres/indexes.txt
+++ b/docs/ref/contrib/postgres/indexes.txt
@@ -10,7 +10,7 @@ available from the ``django.contrib.postgres.indexes`` module.
``BloomIndex``
==============
-.. class:: BloomIndex(length=None, columns=(), **options)
+.. class:: BloomIndex(*expressions, length=None, columns=(), **options)
.. versionadded:: 3.1
@@ -30,10 +30,15 @@ available from the ``django.contrib.postgres.indexes`` module.
.. _bloom: https://www.postgresql.org/docs/current/bloom.html
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
``BrinIndex``
=============
-.. class:: BrinIndex(autosummarize=None, pages_per_range=None, **options)
+.. class:: BrinIndex(*expressions, autosummarize=None, pages_per_range=None, **options)
Creates a `BRIN index
<https://www.postgresql.org/docs/current/brin-intro.html>`_.
@@ -43,24 +48,34 @@ available from the ``django.contrib.postgres.indexes`` module.
The ``pages_per_range`` argument takes a positive integer.
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
.. _automatic summarization: https://www.postgresql.org/docs/current/brin-intro.html#BRIN-OPERATION
``BTreeIndex``
==============
-.. class:: BTreeIndex(fillfactor=None, **options)
+.. class:: BTreeIndex(*expressions, fillfactor=None, **options)
Creates a B-Tree index.
Provide an integer value from 10 to 100 to the fillfactor_ parameter to
tune how packed the index pages will be. PostgreSQL's default is 90.
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
.. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
``GinIndex``
============
-.. class:: GinIndex(fastupdate=None, gin_pending_list_limit=None, **options)
+.. class:: GinIndex(*expressions, fastupdate=None, gin_pending_list_limit=None, **options)
Creates a `gin index <https://www.postgresql.org/docs/current/gin.html>`_.
@@ -79,13 +94,18 @@ available from the ``django.contrib.postgres.indexes`` module.
to tune the maximum size of the GIN pending list which is used when
``fastupdate`` is enabled.
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
.. _GIN Fast Update Technique: https://www.postgresql.org/docs/current/gin-implementation.html#GIN-FAST-UPDATE
.. _gin_pending_list_limit: https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-GIN-PENDING-LIST-LIMIT
``GistIndex``
=============
-.. class:: GistIndex(buffering=None, fillfactor=None, **options)
+.. class:: GistIndex(*expressions, buffering=None, fillfactor=None, **options)
Creates a `GiST index
<https://www.postgresql.org/docs/current/gist.html>`_. These indexes are
@@ -109,13 +129,18 @@ available from the ``django.contrib.postgres.indexes`` module.
Provide an integer value from 10 to 100 to the fillfactor_ parameter to
tune how packed the index pages will be. PostgreSQL's default is 90.
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
.. _buffering build: https://www.postgresql.org/docs/current/gist-implementation.html#GIST-BUFFERING-BUILD
.. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
``HashIndex``
=============
-.. class:: HashIndex(fillfactor=None, **options)
+.. class:: HashIndex(*expressions, fillfactor=None, **options)
Creates a hash index.
@@ -127,12 +152,17 @@ available from the ``django.contrib.postgres.indexes`` module.
Hash indexes have been available in PostgreSQL for a long time, but
they suffer from a number of data integrity issues in older versions.
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
.. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
``SpGistIndex``
===============
-.. class:: SpGistIndex(fillfactor=None, **options)
+.. class:: SpGistIndex(*expressions, fillfactor=None, **options)
Creates an `SP-GiST index
<https://www.postgresql.org/docs/current/spgist.html>`_.
@@ -140,4 +170,30 @@ available from the ``django.contrib.postgres.indexes`` module.
Provide an integer value from 10 to 100 to the fillfactor_ parameter to
tune how packed the index pages will be. PostgreSQL's default is 90.
+ .. versionchanged:: 3.2
+
+ Positional argument ``*expressions`` was added in order to support
+ functional indexes.
+
.. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
+
+``OpClass()`` expressions
+=========================
+
+.. versionadded:: 3.2
+
+.. class:: OpClass(expression, name)
+
+ An ``OpClass()`` expression represents the ``expression`` with a custom
+ `operator class`_ that can be used to define functional indexes. To use it,
+ you need to add ``'django.contrib.postgres'`` in your
+ :setting:`INSTALLED_APPS`. Set the ``name`` parameter to the name of the
+ `operator class`_.
+
+ For example::
+
+ Index(OpClass(Lower('username'), name='varchar_pattern_ops'))
+
+ creates an index on ``Lower('username')`` using ``varchar_pattern_ops``.
+
+ .. _operator class: https://www.postgresql.org/docs/current/indexes-opclass.html