1.The Default B-Tree Index
CREATE INDEX with no method specified creates a B-tree index — PostgreSQL's general-purpose, default index type, built as a balanced tree structure that keeps entries sorted, so any equality or range comparison can find its starting point in roughly logarithmic time rather than scanning everything.
Key features
- CREATE INDEX ON table (column) with no USING clause creates a B-tree index — it is the default method
- B-tree indexes fit the most common situations, per PostgreSQL's own documentation, and are the right starting choice absent a specific reason otherwise
- A B-tree keeps its entries sorted and self-balances as data is inserted, updated and deleted, keeping search cost consistent rather than degrading over time
- Only B-tree indexes can be declared UNIQUE — this is one of several capabilities other index types generally do not offer
- The next several concepts in this section (equality/range/ORDER BY/prefix use cases, composite ordering, partial/expression variants, index-only scans) are all facets of this one index type
- Whole: CREATE INDEX idx_email ON accounts (email);
- CREATE INDEX idx_email — Index name: the name recorded in pg_indexes
- ON accounts — Target table: the table the index is built over
- (email) — Indexed column: sorted, balanced entries for this column
Command
CREATE INDEX idx_email ON accounts (email);
-- equivalent, explicit form:
CREATE INDEX idx_email ON accounts USING btree (email);CREATE INDEX with no USING clause creates a B-tree — the default, general-purpose index type covering the overwhelming majority of real query needs (equality, range, ORDER BY). Only B-tree indexes can be UNIQUE. Reach for a specialized index type only when a specific need justifies it, not as a default habit.