indexes.txt 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. =================================
  2. PostgreSQL specific model indexes
  3. =================================
  4. .. module:: django.contrib.postgres.indexes
  5. The following are PostgreSQL specific :doc:`indexes </ref/models/indexes>`
  6. available from the ``django.contrib.postgres.indexes`` module.
  7. ``BrinIndex``
  8. =============
  9. .. class:: BrinIndex(autosummarize=None, pages_per_range=None, **options)
  10. Creates a `BRIN index
  11. <https://www.postgresql.org/docs/current/brin-intro.html>`_.
  12. Set the ``autosummarize`` parameter to ``True`` to enable `automatic
  13. summarization`_ to be performed by autovacuum.
  14. The ``pages_per_range`` argument takes a positive integer.
  15. .. _automatic summarization: https://www.postgresql.org/docs/current/brin-intro.html#BRIN-OPERATION
  16. .. versionchanged:: 2.2
  17. The ``autosummarize`` parameter was added.
  18. ``BTreeIndex``
  19. ==============
  20. .. class:: BTreeIndex(fillfactor=None, **options)
  21. .. versionadded:: 2.2
  22. Creates a B-Tree index.
  23. Provide an integer value from 10 to 100 to the fillfactor_ parameter to
  24. tune how packed the index pages will be. PostgreSQL's default is 90.
  25. .. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
  26. ``GinIndex``
  27. ============
  28. .. class:: GinIndex(fastupdate=None, gin_pending_list_limit=None, **options)
  29. Creates a `gin index <https://www.postgresql.org/docs/current/gin.html>`_.
  30. To use this index on data types not in the `built-in operator classes
  31. <https://www.postgresql.org/docs/current/gin-builtin-opclasses.html>`_,
  32. you need to activate the `btree_gin extension
  33. <https://www.postgresql.org/docs/current/btree-gin.html>`_ on
  34. PostgreSQL. You can install it using the
  35. :class:`~django.contrib.postgres.operations.BtreeGinExtension` migration
  36. operation.
  37. Set the ``fastupdate`` parameter to ``False`` to disable the `GIN Fast
  38. Update Technique`_ that's enabled by default in PostgreSQL.
  39. Provide an integer number of bytes to the gin_pending_list_limit_ parameter
  40. to tune the maximum size of the GIN pending list which is used when
  41. ``fastupdate`` is enabled.
  42. .. _GIN Fast Update Technique: https://www.postgresql.org/docs/current/gin-implementation.html#GIN-FAST-UPDATE
  43. .. _gin_pending_list_limit: https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-GIN-PENDING-LIST-LIMIT
  44. ``GistIndex``
  45. =============
  46. .. class:: GistIndex(buffering=None, fillfactor=None, **options)
  47. Creates a `GiST index
  48. <https://www.postgresql.org/docs/current/gist.html>`_. These indexes are
  49. automatically created on spatial fields with :attr:`spatial_index=True
  50. <django.contrib.gis.db.models.BaseSpatialField.spatial_index>`. They're
  51. also useful on other types, such as
  52. :class:`~django.contrib.postgres.fields.HStoreField` or the :ref:`range
  53. fields <range-fields>`.
  54. To use this index on data types not in the built-in `gist operator classes
  55. <https://www.postgresql.org/docs/current/gist-builtin-opclasses.html>`_,
  56. you need to activate the `btree_gist extension
  57. <https://www.postgresql.org/docs/current/btree-gist.html>`_ on PostgreSQL.
  58. You can install it using the
  59. :class:`~django.contrib.postgres.operations.BtreeGistExtension` migration
  60. operation.
  61. Set the ``buffering`` parameter to ``True`` or ``False`` to manually enable
  62. or disable `buffering build`_ of the index.
  63. Provide an integer value from 10 to 100 to the fillfactor_ parameter to
  64. tune how packed the index pages will be. PostgreSQL's default is 90.
  65. .. _buffering build: https://www.postgresql.org/docs/current/gist-implementation.html#GIST-BUFFERING-BUILD
  66. .. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
  67. ``HashIndex``
  68. =============
  69. .. class:: HashIndex(fillfactor=None, **options)
  70. .. versionadded:: 2.2
  71. Creates a hash index.
  72. Provide an integer value from 10 to 100 to the fillfactor_ parameter to
  73. tune how packed the index pages will be. PostgreSQL's default is 90.
  74. .. admonition:: Use this index only on PostgreSQL 10 and later
  75. Hash indexes have been available in PostgreSQL for a long time, but
  76. they suffer from a number of data integrity issues in older versions.
  77. .. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS
  78. ``SpGistIndex``
  79. ===============
  80. .. class:: SpGistIndex(fillfactor=None, **options)
  81. .. versionadded:: 2.2
  82. Creates an `SP-GiST index
  83. <https://www.postgresql.org/docs/current/spgist.html>`_.
  84. Provide an integer value from 10 to 100 to the fillfactor_ parameter to
  85. tune how packed the index pages will be. PostgreSQL's default is 90.
  86. .. _fillfactor: https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS