How to Create an Index in PostgreSQL
Last updated July 25, 2026 · By the SaturnSQL team
Use CREATE INDEX ON table (column). A plain CREATE INDEX blocks writes for the duration, so on production tables use CREATE INDEX CONCURRENTLY, which builds without locking but cannot run inside a transaction.
CREATE INDEX idx_orders_customer_id ON orders (customer_id);On a live production table
CREATE INDEX CONCURRENTLY idx_orders_created_at ON orders (created_at);CONCURRENTLY takes roughly twice as long and leaves an INVALID index behind if it fails; drop it and retry. Multi-column indexes only help queries that filter on the leading column(s).
Run this in SaturnSQL
SaturnSQL is a browser-based SQL editor for teams: shared query library, schema-aware autocomplete, and scheduled exports to Google Sheets and Slack.
Try it free