{"Entry":{"collection":"indexam","key":"gin","name":"GIN","aliases":["generalized inverted index","jsonb","array","full text"],"metadata":{"aliases":["generalized inverted index","jsonb","array","full text"],"category":"Component search","content_hash":"56f02c5617a82efb8bdc9eb15485745b759076aa25142972c18d05f7a6632ccf","imported_at":"2026-09-30T00:40:37.234332+08:00","name":"GIN","name_zh":"GIN","slug":"gin","summary":"GIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values."}},"Definition":{"Collection":"indexam","Key":"gin","SourceDatabase":"center","Version":"18","SourceTable":"index_am","SourceKey":"gin","SourceRevision":"0e39ebd4fddbd990280e62f4503f0bd18765bbd990dccf4cba976b5d47da45e7","Facts":{"capabilities":[{"evidence":[{"anchor":"INDEXES-ORDERING","file":"indexes-ordering.html","label":"PostgreSQL 18.6 · indexes-ordering","quote":"In addition to simply finding the rows to be returned by a query, an index may be able to deliver them in a specific sorted order. This allows a query's ORDER BY specification to be honored without a separate sorting step. Of the index types currently supported by PostgreSQL , only B-tree can produce sorted output — the other index types return matching rows in an unspecified, implementation-dependent order.","sha256":"85fac99c7c66ed19dd021f12b5cc53ce18aa5bfa4b56c8c168317f99b8f12d3b","url":"/docs/18/indexes-ordering.html#INDEXES-ORDERING"}],"key":"ordered","label":"Sorted output","note":"Ordinary sorted output is distinct from ordering by an operator, such as nearest-neighbor distance.","state":"no","value":"No"},{"evidence":[{"anchor":"INDEXES-UNIQUE","file":"indexes-unique.html","label":"PostgreSQL 18.6 · indexes-unique","quote":"Currently, only B-tree indexes can be declared unique.","sha256":"7c3eac7fa180b22534ff01df0c68155f15b6b360ffe35507c5266059116840db","url":"/docs/18/indexes-unique.html#INDEXES-UNIQUE"}],"key":"unique","label":"Unique keys","note":"This means a unique index. Exclusion constraints use a different contract.","state":"no","value":"No"},{"evidence":[{"anchor":"INDEXES-MULTICOLUMN","file":"indexes-multicolumn.html","label":"PostgreSQL 18.6 · indexes-multicolumn","quote":"Currently, only the B-tree, GiST, GIN, and BRIN index types support multiple-key-column indexes. Whether there can be multiple key columns is independent of whether INCLUDE columns can be added to the index. Indexes can have up to 32 columns, including INCLUDE columns. (This limit can be altered when building PostgreSQL ; see the file pg_config_manual.h .)","sha256":"c0a799ec49b8ef057a63d465fb1d72a3b81e16d652c28a71734d45592d081202","url":"/docs/18/indexes-multicolumn.html#INDEXES-MULTICOLUMN"}],"key":"multicolumn","label":"Multiple key columns","note":"Multiple search keys are distinct from non-key INCLUDE payload columns.","state":"yes","value":"Yes"},{"evidence":[{"anchor":"SQL-CREATEINDEX","file":"sql-createindex.html","label":"PostgreSQL 18.6 · sql-createindex","quote":"Currently, the B-tree, GiST and SP-GiST index access methods support this feature. In these indexes, the values of columns listed in the INCLUDE clause are included in leaf tuples which correspond to heap tuples, but are not included in upper-level index entries used for tree navigation.","sha256":"6aa00da55815d13d0355dd25cb1cdb603fa36964993f164d1b6f486011282580","url":"/docs/18/sql-createindex.html#SQL-CREATEINDEX"}],"key":"include","label":"INCLUDE columns","note":"Payload columns do not become search keys. Wide payloads can exceed the index tuple-size limit.","state":"no","value":"No"},{"evidence":[{"anchor":"INDEXES-INDEX-ONLY-SCANS","file":"indexes-index-only-scans.html","label":"PostgreSQL 18.6 · indexes-index-only-scans","quote":"The index type must support index-only scans. B-tree indexes always do. GiST and SP-GiST indexes support index-only scans for some operator classes but not others. Other index types have no support. The underlying requirement is that the index must physically store, or else be able to reconstruct, the original data value for each index entry. As a counterexample, GIN indexes cannot support index-only scans because each index entry typically holds only part of the original data value.","sha256":"2322ec12b82f3fd01ee4072049caaa5a0190148ac68d98c0fcd6eda958828a83","url":"/docs/18/indexes-index-only-scans.html#INDEXES-INDEX-ONLY-SCANS"}],"key":"index_only","label":"Index-only scans","note":"The query must use covered values; visibility-map state determines whether heap visits can be avoided.","state":"no","value":"No"},{"evidence":[],"key":"distance","label":"Distance ordering","note":"Availability depends on the chosen operator class and ordering operator.","state":"unknown","value":"Not established"},{"evidence":[{"anchor":"PARALLEL-SCANS","file":"parallel-plans.html","label":"PostgreSQL 18.6 · parallel-plans","quote":"In a parallel index scan or parallel index-only scan , the cooperating processes take turns reading data from the index. Currently, parallel index scans are supported only for btree indexes. Each process will claim a single index block and will scan and return all tuples referenced by that block; other processes can at the same time be returning tuples from a different index block. The results of a parallel btree scan are returned in sorted order within each worker process.","sha256":"62207d207bead82b01b59dc119c4f95856f08655cc11d4699a05a40867ed2070","url":"/docs/18/parallel-plans.html#PARALLEL-SCANS"}],"key":"parallel_scan","label":"Parallel index scan","note":"A cooperating scan of one index is distinct from a parallel bitmap heap scan or separate serial scans under Parallel Append.","state":"no","value":"No"},{"evidence":[{"anchor":"SQL-CREATEINDEX","file":"sql-createindex.html","label":"PostgreSQL 18.6 · sql-createindex","quote":"PostgreSQL can build indexes while leveraging multiple CPUs in order to process the table rows faster. This feature is known as parallel index build . For index methods that support building indexes in parallel (currently, B-tree, GIN, and BRIN), maintenance_work_mem specifies the maximum amount of memory that can be used by each index build operation as a whole, regardless of how many worker processes were started. Generally, a cost model automatically determines how many worker processes should be requested, if any.","sha256":"6aa00da55815d13d0355dd25cb1cdb603fa36964993f164d1b6f486011282580","url":"/docs/18/sql-createindex.html#SQL-CREATEINDEX"}],"key":"parallel_build","label":"Parallel index build","note":"Parallel construction is separate from parallel scans. Worker availability, settings and build phases also matter.","state":"yes","value":"Yes"}],"description":["GIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values."],"evidence_kind":"documentation","facts":[{"label":"Sorted output","value":"No"},{"label":"Unique keys","value":"No"},{"label":"Multiple key columns","value":"Yes"},{"label":"INCLUDE columns","value":"No"},{"label":"Index-only scans","value":"No"},{"label":"Distance ordering","value":"Not established"},{"label":"Parallel index scan","value":"No"},{"label":"Parallel index build","value":"Yes"}],"related":[{"label":"9.19. Array Functions and Operators","url":"/docs/18/functions-array.html"},{"label":"Table 65.3. Built-in GIN Operator Classes","url":"/docs/18/gin.html#GIN-BUILTIN-OPCLASSES-TABLE"},{"label":"65.4. GIN Indexes","url":"/docs/18/gin.html"},{"label":"pg_am","url":"/wiki/catalog/pg_am/?v=18"},{"label":"pg_opclass","url":"/wiki/catalog/pg_opclass/?v=18"},{"label":"pg_opfamily","url":"/wiki/catalog/pg_opfamily/?v=18"},{"label":"pg_amop","url":"/wiki/catalog/pg_amop/?v=18"},{"label":"pg_amproc","url":"/wiki/catalog/pg_amproc/?v=18"},{"label":"CREATE INDEX","url":"/wiki/sql/create-index/?v=18"},{"label":"Operator classes and families","url":"/docs/18/indexes-opclass.html"},{"label":"Index access method interface","url":"/docs/18/indexam.html"},{"label":"Storage parameters","url":"/wiki/relopts/?v=18"},{"label":"gin_pending_list_limit","url":"/wiki/guc/gin_pending_list_limit/?v=18"}],"release":{"channel":"stable","evidence_kind":"English manual extraction","label":"18.6","major":"18","manifest":{"major":"18","release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},"ref":"PostgreSQL 18.6 Documentation","revision":"0e39ebd4fddbd990280e62f4503f0bd18765bbd990dccf4cba976b5d47da45e7"},"runtime_verified":false,"sections":[{"blocks":[{"paragraphs":["GIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values."]},{"paragraphs":["Like GiST and SP-GiST, GIN can support many different user-defined indexing strategies, and the particular operators with which a GIN index can be used vary depending on the indexing strategy. As an example, the standard distribution of PostgreSQL includes a GIN operator class for arrays, which supports indexed queries using these operators:"]},{"code":"\u003c@   @\u003e   =   \u0026\u0026","paragraphs":[]},{"paragraphs":["(See Section 9.19 for the meaning of these operators.) The GIN operator classes included in the standard distribution are documented in Table 65.3 . Many other GIN operator classes are available in the contrib collection or as separate projects. For more information see Section 65.4 ."]}],"title":"Queries, operators and limitations"}],"signature":"CREATE INDEX name ON table_name USING gin (column_name);","sources":[{"anchor":"INDEXES-TYPES-GIN","file":"indexes-types.html","label":"PostgreSQL 18.6: GIN","sha256":"cee340145a2ef5fbd807f66755b10d22bb049e328c460f572f45ad6193e7e4a1","url":"/docs/18/indexes-types.html#INDEXES-TYPES-GIN"},{"anchor":"","file":"catalog-pg-am.html","label":"PostgreSQL 18.6 · catalog-pg-am","sha256":"579364179365a51945e2edb6481df5d198916c2c725e506f166824dedf08994c","url":"/docs/18/catalog-pg-am.html"},{"anchor":"","file":"hash-index.html","label":"PostgreSQL 18.6 · hash-index","sha256":"b994550220e1ee05648d09804c9eb2302834e07e261932420a96605d7c9c6140","url":"/docs/18/hash-index.html"},{"anchor":"","file":"indexam.html","label":"PostgreSQL 18.6 · indexam","sha256":"0a38f7c0ac0541f31e086c83a624e782c15367456578a6dd3329882516bc1080","url":"/docs/18/indexam.html"},{"anchor":"","file":"indexes-index-only-scans.html","label":"PostgreSQL 18.6 · indexes-index-only-scans","sha256":"2322ec12b82f3fd01ee4072049caaa5a0190148ac68d98c0fcd6eda958828a83","url":"/docs/18/indexes-index-only-scans.html"},{"anchor":"","file":"indexes-multicolumn.html","label":"PostgreSQL 18.6 · indexes-multicolumn","sha256":"c0a799ec49b8ef057a63d465fb1d72a3b81e16d652c28a71734d45592d081202","url":"/docs/18/indexes-multicolumn.html"},{"anchor":"","file":"indexes-opclass.html","label":"PostgreSQL 18.6 · indexes-opclass","sha256":"07de06abf3a2aff2a891a2789def434d9b76705e54d45ca5338dc13451ae2962","url":"/docs/18/indexes-opclass.html"},{"anchor":"","file":"indexes-ordering.html","label":"PostgreSQL 18.6 · indexes-ordering","sha256":"85fac99c7c66ed19dd021f12b5cc53ce18aa5bfa4b56c8c168317f99b8f12d3b","url":"/docs/18/indexes-ordering.html"},{"anchor":"","file":"indexes-unique.html","label":"PostgreSQL 18.6 · indexes-unique","sha256":"7c3eac7fa180b22534ff01df0c68155f15b6b360ffe35507c5266059116840db","url":"/docs/18/indexes-unique.html"},{"anchor":"","file":"parallel-plans.html","label":"PostgreSQL 18.6 · parallel-plans","sha256":"62207d207bead82b01b59dc119c4f95856f08655cc11d4699a05a40867ed2070","url":"/docs/18/parallel-plans.html"},{"anchor":"","file":"sql-createindex.html","label":"PostgreSQL 18.6 · sql-createindex","sha256":"6aa00da55815d13d0355dd25cb1cdb603fa36964993f164d1b6f486011282580","url":"/docs/18/sql-createindex.html"}],"storage_options":[{"description":["Controls usage of the fast update technique described in Section 65.4.4.1 . ON enables fast update, OFF disables it. The default is ON .","Turning fastupdate off via ALTER INDEX prevents future insertions from going into the list of pending index entries, but does not in itself flush existing entries. You might want to VACUUM the table or call the gin_clean_pending_list function afterward to ensure the pending list is emptied."],"name":"fastupdate","source":{"anchor":"INDEX-RELOPTION-FASTUPDATE","file":"sql-createindex.html","label":"PostgreSQL 18.6 · sql-createindex","sha256":"6aa00da55815d13d0355dd25cb1cdb603fa36964993f164d1b6f486011282580","url":"/docs/18/sql-createindex.html#INDEX-RELOPTION-FASTUPDATE"},"url":"/wiki/relopts/gin-fastupdate/?v=18"},{"description":["Overrides the global setting of gin_pending_list_limit for this index. This value is specified in kilobytes."],"name":"gin_pending_list_limit","source":{"anchor":"INDEX-RELOPTION-GIN-PENDING-LIST-LIMIT","file":"sql-createindex.html","label":"PostgreSQL 18.6 · sql-createindex","sha256":"6aa00da55815d13d0355dd25cb1cdb603fa36964993f164d1b6f486011282580","url":"/docs/18/sql-createindex.html#INDEX-RELOPTION-GIN-PENDING-LIST-LIMIT"},"url":"/wiki/relopts/gin-gin-pending-list-limit/?v=18"}]},"ManualEvidence":{"release":{"channel":"stable","evidence_kind":"English manual extraction","label":"18.6","major":"18","manifest":{"major":"18","release":"18.6","source_mode":"en SGML built with pinned official archive","source_sha256":"555610c24d53e4316da5b7d3fc25c279d96856d5e0e23ee308c328c5fa881d9f","source_url":"https://ftp.postgresql.org/pub/source/v18.6/postgresql-18.6.tar.bz2"},"ref":"PostgreSQL 18.6 Documentation","revision":"0e39ebd4fddbd990280e62f4503f0bd18765bbd990dccf4cba976b5d47da45e7"},"sources":[{"anchor":"INDEXES-TYPES-GIN","file":"indexes-types.html","label":"PostgreSQL 18.6: GIN","sha256":"cee340145a2ef5fbd807f66755b10d22bb049e328c460f572f45ad6193e7e4a1","url":"/docs/18/indexes-types.html#INDEXES-TYPES-GIN"},{"anchor":"","file":"catalog-pg-am.html","label":"PostgreSQL 18.6 · catalog-pg-am","sha256":"579364179365a51945e2edb6481df5d198916c2c725e506f166824dedf08994c","url":"/docs/18/catalog-pg-am.html"},{"anchor":"","file":"hash-index.html","label":"PostgreSQL 18.6 · hash-index","sha256":"b994550220e1ee05648d09804c9eb2302834e07e261932420a96605d7c9c6140","url":"/docs/18/hash-index.html"},{"anchor":"","file":"indexam.html","label":"PostgreSQL 18.6 · indexam","sha256":"0a38f7c0ac0541f31e086c83a624e782c15367456578a6dd3329882516bc1080","url":"/docs/18/indexam.html"},{"anchor":"","file":"indexes-index-only-scans.html","label":"PostgreSQL 18.6 · indexes-index-only-scans","sha256":"2322ec12b82f3fd01ee4072049caaa5a0190148ac68d98c0fcd6eda958828a83","url":"/docs/18/indexes-index-only-scans.html"},{"anchor":"","file":"indexes-multicolumn.html","label":"PostgreSQL 18.6 · indexes-multicolumn","sha256":"c0a799ec49b8ef057a63d465fb1d72a3b81e16d652c28a71734d45592d081202","url":"/docs/18/indexes-multicolumn.html"},{"anchor":"","file":"indexes-opclass.html","label":"PostgreSQL 18.6 · indexes-opclass","sha256":"07de06abf3a2aff2a891a2789def434d9b76705e54d45ca5338dc13451ae2962","url":"/docs/18/indexes-opclass.html"},{"anchor":"","file":"indexes-ordering.html","label":"PostgreSQL 18.6 · indexes-ordering","sha256":"85fac99c7c66ed19dd021f12b5cc53ce18aa5bfa4b56c8c168317f99b8f12d3b","url":"/docs/18/indexes-ordering.html"},{"anchor":"","file":"indexes-unique.html","label":"PostgreSQL 18.6 · indexes-unique","sha256":"7c3eac7fa180b22534ff01df0c68155f15b6b360ffe35507c5266059116840db","url":"/docs/18/indexes-unique.html"},{"anchor":"","file":"parallel-plans.html","label":"PostgreSQL 18.6 · parallel-plans","sha256":"62207d207bead82b01b59dc119c4f95856f08655cc11d4699a05a40867ed2070","url":"/docs/18/parallel-plans.html"},{"anchor":"","file":"sql-createindex.html","label":"PostgreSQL 18.6 · sql-createindex","sha256":"6aa00da55815d13d0355dd25cb1cdb603fa36964993f164d1b6f486011282580","url":"/docs/18/sql-createindex.html"}]},"MeasuredEvidence":{"runtime_verified":false}},"Text":{"Collection":"indexam","Key":"gin","SourceDatabase":"center","Version":"18","Locale":"en","Title":"GIN","Summary":"GIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values.","BodyHTML":"\u003cp\u003eGIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values.\u003c/p\u003e","SourceRevision":"0e39ebd4fddbd990280e62f4503f0bd18765bbd990dccf4cba976b5d47da45e7","ContentHash":"572b4e5d74c000825da7a6bdd8ea1960f041e8f9e70dba74ae7521b60471a145","Payload":{"description":["GIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values."],"related":[{"label":"9.19. Array Functions and Operators","url":"/docs/18/functions-array.html"},{"label":"Table 65.3. Built-in GIN Operator Classes","url":"/docs/18/gin.html#GIN-BUILTIN-OPCLASSES-TABLE"},{"label":"65.4. GIN Indexes","url":"/docs/18/gin.html"},{"label":"pg_am","url":"/wiki/catalog/pg_am/?v=18"},{"label":"pg_opclass","url":"/wiki/catalog/pg_opclass/?v=18"},{"label":"pg_opfamily","url":"/wiki/catalog/pg_opfamily/?v=18"},{"label":"pg_amop","url":"/wiki/catalog/pg_amop/?v=18"},{"label":"pg_amproc","url":"/wiki/catalog/pg_amproc/?v=18"},{"label":"CREATE INDEX","url":"/wiki/sql/create-index/?v=18"},{"label":"Operator classes and families","url":"/docs/18/indexes-opclass.html"},{"label":"Index access method interface","url":"/docs/18/indexam.html"},{"label":"Storage parameters","url":"/wiki/relopts/?v=18"},{"label":"gin_pending_list_limit","url":"/wiki/guc/gin_pending_list_limit/?v=18"}],"sections":[{"blocks":[{"paragraphs":["GIN indexes are “ inverted indexes ” which are appropriate for data values that contain multiple component values, such as arrays. An inverted index contains a separate entry for each component value, and can efficiently handle queries that test for the presence of specific component values."]},{"paragraphs":["Like GiST and SP-GiST, GIN can support many different user-defined indexing strategies, and the particular operators with which a GIN index can be used vary depending on the indexing strategy. As an example, the standard distribution of PostgreSQL includes a GIN operator class for arrays, which supports indexed queries using these operators:"]},{"code":"\u003c@   @\u003e   =   \u0026\u0026","paragraphs":[]},{"paragraphs":["(See Section 9.19 for the meaning of these operators.) The GIN operator classes included in the standard distribution are documented in Table 65.3 . Many other GIN operator classes are available in the contrib collection or as separate projects. For more information see Section 65.4 ."]}],"title":"Queries, operators and limitations"}]}},"RequestedLocale":"zh-Hans","Fallback":true,"Versions":["10","11","12","13","14","15","16","17","18","19","20","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
