indexes.txt 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. ``GistIndex``
  33. =============
  34. .. class:: GistIndex(buffering=None, fillfactor=None, **options)
  35. Creates a `GiST index
  36. <https://www.postgresql.org/docs/current/static/gist.html>`_. These indexes
  37. are automatically created on spatial fields with :attr:`spatial_index=True
  38. <django.contrib.gis.db.models.BaseSpatialField.spatial_index>`. They're
  39. also useful on other types, such as
  40. :class:`~django.contrib.postgres.fields.HStoreField` or the :ref:`range
  41. fields <range-fields>`.
  42. To use this index on data types not in the built-in `gist operator classes
  43. <https://www.postgresql.org/docs/current/static/gist-builtin-opclasses.html>`_,
  44. you need to activate the `btree_gist extension
  45. <https://www.postgresql.org/docs/current/static/btree-gist.html>`_ on
  46. PostgreSQL. You can install it using the
  47. :class:`~django.contrib.postgres.operations.BtreeGistExtension` migration
  48. operation.
  49. Set the ``buffering`` parameter to ``True`` or ``False`` to manually enable
  50. or disable `buffering build`_ of the index.
  51. Provide an integer value from 10 to 100 to the fillfactor_ parameter to
  52. tune how packed the index pages will be. PostgreSQL's default is 90.
  53. .. _buffering build: https://www.postgresql.org/docs/current/static/gist-implementation.html#GIST-BUFFERING-BUILD
  54. .. _fillfactor: https://www.postgresql.org/docs/current/static/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS