indexes.txt 3.3 KB

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