Skip to content
masterclass Buddy

PostgreSQL · Command

CREATE INDEX

CREATE INDEX builds an index on a table or materialized view. It can index columns or expressions and can support faster searches, sorting, partial indexes, and index-only scans.

Last updated

Syntax

CREATE [ UNIQUE ] INDEX [ CONCURRENTLY ] [ [ IF NOT EXISTS ] name ] ON [ ONLY ] table_name [ USING method ] ( { column_name | ( expression ) } [ COLLATE collation ] [ opclass [ ( opclass_parameter = value [, ... ] ) ] ] [ ASC | DESC ] [ NULLS { FIRST | LAST } ] [, ...] ) [ INCLUDE ( column_name [, ...] ) ] [ NULLS [ NOT ] DISTINCT ] [ WITH ( storage_parameter [= value ] [, ...] ) ] [ TABLESPACE tablespace_name ] [ WHERE predicate ]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • CREATE TABLE
  • ALTER INDEX
  • ANALYZE
  • maintenance_work_mem
  • index-only scan
  • partial index
  • B-tree
  • GiST

Source: CREATE INDEX. Checked 2026-11-03.