{"title":"PostgreSQL specific model indexes","version":"2.2","locale":"es","docname":"ref/contrib/postgres/indexes","url":"/es/2.2/ref/contrib/postgres/indexes/","canonical":"https://djangodocs.dev/es/2.2/ref/contrib/postgres/indexes/","summary":"The following are PostgreSQL specific indexes available from the django.contrib.postgres.indexes module. BrinIndex Link to this heading # class BrinIndex (…","html":"<span id=\"postgresql-specific-model-indexes\"></span><h1>PostgreSQL specific model indexes<a class=\"heading-anchor\" href=\"#module-django.contrib.postgres.indexes\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>The following are PostgreSQL specific <a class=\"reference internal\" href=\"/es/2.2/ref/models/indexes/\"><span class=\"doc\">indexes</span></a>\navailable from the <code class=\"docutils literal notranslate\"><span class=\"pre\">django.contrib.postgres.indexes</span></code> module.</p>\n<section id=\"brinindex\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">BrinIndex</span></code><a class=\"heading-anchor\" href=\"#brinindex\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.postgres.indexes.BrinIndex\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">BrinIndex</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">autosummarize</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">pages_per_range</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.postgres.indexes.BrinIndex\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Creates a <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/brin-intro.html\">BRIN index</a>.</p>\n<p>Set the <code class=\"docutils literal notranslate\"><span class=\"pre\">autosummarize</span></code> parameter to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> to enable <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/brin-intro.html#BRIN-OPERATION\">automatic\nsummarization</a> to be performed by autovacuum.</p>\n<p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">pages_per_range</span></code> argument takes a positive integer.</p>\n<aside class=\"version-note version-changed\" data-version=\"2.2\">\n<p class=\"version-note-title\">Changed in Django 2.2</p><p>The <code class=\"docutils literal notranslate\"><span class=\"pre\">autosummarize</span></code> parameter was added.</p>\n</aside>\n</dd></dl>\n\n</section>\n<section id=\"btreeindex\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">BTreeIndex</span></code><a class=\"heading-anchor\" href=\"#btreeindex\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.postgres.indexes.BTreeIndex\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">BTreeIndex</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">fillfactor</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.postgres.indexes.BTreeIndex\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Creates a B-Tree index.</p>\n<p>Provide an integer value from 10 to 100 to the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS\">fillfactor</a> parameter to\ntune how packed the index pages will be. PostgreSQL’s default is 90.</p>\n</dd></dl>\n\n</section>\n<section id=\"ginindex\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">GinIndex</span></code><a class=\"heading-anchor\" href=\"#ginindex\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.postgres.indexes.GinIndex\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">GinIndex</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">fastupdate</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">gin_pending_list_limit</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.postgres.indexes.GinIndex\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Creates a <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/gin.html\">gin index</a>.</p>\n<p>To use this index on data types not in the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/gin-builtin-opclasses.html\">built-in operator classes</a>,\nyou need to activate the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/btree-gin.html\">btree_gin extension</a> on\nPostgreSQL. You can install it using the\n<a class=\"reference internal\" href=\"/es/2.2/ref/contrib/postgres/operations/#django.contrib.postgres.operations.BtreeGinExtension\" title=\"django.contrib.postgres.operations.BtreeGinExtension\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">BtreeGinExtension</span></code></a> migration\noperation.</p>\n<p>Set the <code class=\"docutils literal notranslate\"><span class=\"pre\">fastupdate</span></code> parameter to <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code> to disable the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/gin-implementation.html#GIN-FAST-UPDATE\">GIN Fast\nUpdate Technique</a> that’s enabled by default in PostgreSQL.</p>\n<p>Provide an integer number of bytes to the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-GIN-PENDING-LIST-LIMIT\">gin_pending_list_limit</a> parameter\nto tune the maximum size of the GIN pending list which is used when\n<code class=\"docutils literal notranslate\"><span class=\"pre\">fastupdate</span></code> is enabled. This parameter requires PostgreSQL ≥ 9.5.</p>\n</dd></dl>\n\n</section>\n<section id=\"gistindex\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">GistIndex</span></code><a class=\"heading-anchor\" href=\"#gistindex\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.postgres.indexes.GistIndex\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">GistIndex</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">buffering</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">fillfactor</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.postgres.indexes.GistIndex\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><p>Creates a <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/gist.html\">GiST index</a>. These indexes are\nautomatically created on spatial fields with <a class=\"reference internal\" href=\"/es/2.2/ref/contrib/gis/model-api/#django.contrib.gis.db.models.BaseSpatialField.spatial_index\" title=\"django.contrib.gis.db.models.BaseSpatialField.spatial_index\"><code class=\"xref py py-attr docutils literal notranslate\"><span class=\"pre\">spatial_index=True</span></code></a>. They’re\nalso useful on other types, such as\n<a class=\"reference internal\" href=\"/es/2.2/ref/contrib/postgres/fields/#django.contrib.postgres.fields.HStoreField\" title=\"django.contrib.postgres.fields.HStoreField\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">HStoreField</span></code></a> or the <a class=\"reference internal\" href=\"/es/2.2/ref/contrib/postgres/fields/#range-fields\"><span class=\"std std-ref\">range\nfields</span></a>.</p>\n<p>To use this index on data types not in the built-in <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/gist-builtin-opclasses.html\">gist operator classes</a>,\nyou need to activate the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/btree-gist.html\">btree_gist extension</a> on PostgreSQL.\nYou can install it using the\n<a class=\"reference internal\" href=\"/es/2.2/ref/contrib/postgres/operations/#django.contrib.postgres.operations.BtreeGistExtension\" title=\"django.contrib.postgres.operations.BtreeGistExtension\"><code class=\"xref py py-class docutils literal notranslate\"><span class=\"pre\">BtreeGistExtension</span></code></a> migration\noperation.</p>\n<p>Set the <code class=\"docutils literal notranslate\"><span class=\"pre\">buffering</span></code> parameter to <code class=\"docutils literal notranslate\"><span class=\"pre\">True</span></code> or <code class=\"docutils literal notranslate\"><span class=\"pre\">False</span></code> to manually enable\nor disable <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/gist-implementation.html#GIST-BUFFERING-BUILD\">buffering build</a> of the index.</p>\n<p>Provide an integer value from 10 to 100 to the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS\">fillfactor</a> parameter to\ntune how packed the index pages will be. PostgreSQL’s default is 90.</p>\n</dd></dl>\n\n</section>\n<section id=\"hashindex\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">HashIndex</span></code><a class=\"heading-anchor\" href=\"#hashindex\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.postgres.indexes.HashIndex\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">HashIndex</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">fillfactor</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.postgres.indexes.HashIndex\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Creates a hash index.</p>\n<p>Provide an integer value from 10 to 100 to the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS\">fillfactor</a> parameter to\ntune how packed the index pages will be. PostgreSQL’s default is 90.</p>\n<aside class=\"admonition-use-this-index-only-on-postgresql-10-and-later admonition\">\n<p class=\"admonition-title\">Use this index only on PostgreSQL 10 and later</p>\n<p>Hash indexes have been available in PostgreSQL for a long time, but\nthey suffer from a number of data integrity issues in older versions.</p>\n</aside>\n</dd></dl>\n\n</section>\n<section id=\"spgistindex\">\n<h2><code class=\"docutils literal notranslate\"><span class=\"pre\">SpGistIndex</span></code><a class=\"heading-anchor\" href=\"#spgistindex\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<dl class=\"py class\">\n<dt class=\"sig sig-object py\" id=\"django.contrib.postgres.indexes.SpGistIndex\">\n<em class=\"property\"><span class=\"k\"><span class=\"pre\">class</span></span><span class=\"w\"> </span></em><span class=\"sig-name descname\"><span class=\"pre\">SpGistIndex</span></span><span class=\"sig-paren\">(</span><em class=\"sig-param\"><span class=\"n\"><span class=\"pre\">fillfactor</span></span><span class=\"o\"><span class=\"pre\">=</span></span><span class=\"default_value\"><span class=\"pre\">None</span></span></em>, <em class=\"sig-param\"><span class=\"o\"><span class=\"pre\">**</span></span><span class=\"n\"><span class=\"pre\">options</span></span></em><span class=\"sig-paren\">)</span><a class=\"heading-anchor\" href=\"#django.contrib.postgres.indexes.SpGistIndex\"><span class=\"visually-hidden\">Link to this definition</span><span aria-hidden=\"true\">#</span></a></dt>\n<dd><aside class=\"version-note version-added\" data-version=\"2.2\">\n<p class=\"version-note-title\">New in Django 2.2</p></aside>\n<p>Creates an <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/spgist.html\">SP-GiST index</a>.</p>\n<p>Provide an integer value from 10 to 100 to the <a class=\"reference external\" href=\"https://www.postgresql.org/docs/current/sql-createindex.html#SQL-CREATEINDEX-STORAGE-PARAMETERS\">fillfactor</a> parameter to\ntune how packed the index pages will be. PostgreSQL’s default is 90.</p>\n</dd></dl>\n\n</section>","rootId":"module-django.contrib.postgres.indexes","toc":[{"title":"BrinIndex","anchor":"brinindex","children":[]},{"title":"BTreeIndex","anchor":"btreeindex","children":[]},{"title":"GinIndex","anchor":"ginindex","children":[]},{"title":"GistIndex","anchor":"gistindex","children":[]},{"title":"HashIndex","anchor":"hashindex","children":[]},{"title":"SpGistIndex","anchor":"spgistindex","children":[]}],"breadcrumbs":[{"docname":"ref/index","title":"API Reference","url":"/es/2.2/ref/"},{"docname":"ref/contrib/index","title":"contrib packages","url":"/es/2.2/ref/contrib/"},{"docname":"ref/contrib/postgres/index","title":"django.contrib.postgres","url":"/es/2.2/ref/contrib/postgres/"}],"prev":{"docname":"ref/contrib/postgres/functions","title":"PostgreSQL specific database functions","url":"/es/2.2/ref/contrib/postgres/functions/"},"next":{"docname":"ref/contrib/postgres/lookups","title":"PostgreSQL specific lookups","url":"/es/2.2/ref/contrib/postgres/lookups/"},"formats":{"html":"/es/2.2/ref/contrib/postgres/indexes/","markdown":"/es/2.2/ref/contrib/postgres/indexes.md","json":"/es/2.2/ref/contrib/postgres/indexes.json"},"source":"https://github.com/django/django/blob/stable/2.2.x/docs/ref/contrib/postgres/indexes.txt","official":"https://docs.djangoproject.com/es/2.2/ref/contrib/postgres/indexes/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11"],"inLocales":["en","zh-hans","fr","ja","id","pt-br","ko","es","el","pl"]}