indexes.txt 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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(pages_per_range=None, **options)
  10. Creates a `BRIN index
  11. <https://www.postgresql.org/docs/current/static/brin-intro.html>`_.
  12. The ``pages_per_range`` argument takes a positive integer.
  13. ``GinIndex``
  14. ============
  15. .. class:: GinIndex(fastupdate=None, gin_pending_list_limit=None, **options)
  16. Creates a `gin index
  17. <https://www.postgresql.org/docs/current/static/gin.html>`_.
  18. To use this index on data types not in the `built-in operator classes
  19. <https://www.postgresql.org/docs/current/static/gin-builtin-opclasses.html>`_,
  20. you need to activate the `btree_gin extension
  21. <https://www.postgresql.org/docs/current/static/btree-gin.html>`_ on
  22. PostgreSQL. You can install it using the
  23. :class:`~django.contrib.postgres.operations.BtreeGinExtension` migration
  24. operation.
  25. Set the ``fastupdate`` parameter to ``False`` to disable the `GIN Fast
  26. Update Technique`_ that's enabled by default in PostgreSQL.
  27. Provide an integer number of bytes to the gin_pending_list_limit_ parameter
  28. to tune the maximum size of the GIN pending list which is used when
  29. ``fastupdate`` is enabled. This parameter requires PostgreSQL ≥ 9.5.
  30. .. _GIN Fast Update Technique: https://www.postgresql.org/docs/current/static/gin-implementation.html#GIN-FAST-UPDATE
  31. .. _gin_pending_list_limit: https://www.postgresql.org/docs/current/static/runtime-config-client.html#GUC-GIN-PENDING-LIST-LIMIT
  32. .. versionchanged:: 2.0
  33. The ``fastupdate`` and ``gin_pending_list_limit`` parameters were added.
  34. ``GistIndex``
  35. =============
  36. .. class:: GistIndex(buffering=None, fillfactor=None, **options)
  37. .. versionadded:: 2.0
  38. Creates a `GiST index
  39. <https://www.postgresql.org/docs/current/static/gist.html>`_. These indexes
  40. are automatically created on spatial fields with :attr:`spatial_index=True
  41. <django.contrib.gis.db.models.BaseSpatialField.spatial_index>`. They're
  42. also useful on other types, such as
  43. :class:`~django.contrib.postgres.fields.HStoreField` or the :ref:`range
  44. fields <range-fields>`.
  45. To use this index on data types not in the built-in `gist operator classes
  46. <https://www.postgresql.org/docs/current/static/gist-builtin-opclasses.html>`_,
  47. you need to activate the `btree_gist extension
  48. <https://www.postgresql.org/docs/current/static/btree-gist.html>`_ on
  49. PostgreSQL. You can install it using the
  50. :class:`~django.contrib.postgres.operations.BtreeGistExtension` migration
  51. operation.
  52. Set the ``buffering`` parameter to ``True`` or ``False`` to manually enable
  53. or disable `buffering build`_ of the index.
  54. Provide an integer value from 10 to 100 to the fillfactor_ parameter to
  55. tune how packed the index pages will be. PostgreSQL's default is 90.
  56. .. _buffering build: https://www.postgresql.org/docs/current/static/gist-implementation.html#GIST-BUFFERING-BUILD
  57. .. _fillfactor: https://www.postgresql.org/docs/current/static/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS