index

GIN

Inverted index maps component keys to matching rows; array containment is one use. Updates can be costly. Target: PostgreSQL 17. Use a disposable database; plan selection is not guaranteed.

Formal Syntax & Structure

sql syntaxsql
CREATE INDEX ix ON docs USING gin (tags)

Working Example

Example Snippetsql
CREATE TABLE docs(id int, tags text[]); INSERT INTO docs VALUES (1,ARRAY['sql','db']),(2,ARRAY['go']);CREATE INDEX ix ON docs USING gin (tags);SELECT id FROM docs WHERE tags @> ARRAY['sql'];
SQL Reference