CREATE INDEX
CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ IF NOT EXISTS ] name
ON table_or_collection [ USING { btree | gin } ]
(column [ ASC | DESC ] [ NULLS FIRST | NULLS LAST ] [, ...])
[ WITH (fillfactor = integer) ];
btree is the default for orderable keys. gin supports array containment
(@>) and overlap (&&), and collection content searches on doc with @>.
The index narrows the candidates; the original predicate is rechecked to
preserve exact semantics. For doc, the planner uses GIN only for positive
structural equality filters whose indexed terms are necessary for a match.
Logical or negative operators, equality with null, and empty containers use a
sequential scan. Those filters remain valid and return the same results.
Example GIN index on a collection:
CREATE INDEX events_doc_gin ON events USING gin (doc);
Expressions, partial indexes, and INCLUDE are not available.
For B-tree indexes, fillfactor accepts values from 10 to 100 and defaults to
90. It controls initial leaf-page occupancy. The option is persisted and used
by REINDEX; ALTER INDEX name SET (fillfactor = n) changes the option for the
next rebuild and RESET (fillfactor) returns to the default.