Indexes you declare, and one you do not.
Every column already has the filter index: fingerprints and zone bounds, maintained on write. Declare B-tree, hash or GIN indexes when you want to go straight to a key; the engine picks the method if you do not.
A SELECT, from predicate to answer
Rows are not found through a B-tree. Per-column fingerprints rule out most of the table 512 rows at a time, zone maps rule out whole ranges, and only the candidates left are read.
- 1Predicates extracted
WHERE city = 'Oslo' AND age > 30 is split into an equality the fingerprints can test and a range the zone maps can test.
- 2Zone maps skip ranges
Each zone records min and max per column. Zones whose max age is 30 or less cannot match and are skipped whole.
- 3Fingerprints, 512 at a time
Bit-sliced fingerprint planes for city are compared against 'Oslo' in SIMD: one register answers for 512 rows.
- 4Only candidates are read
The candidate bitmap names the few rows worth fetching. The rest of the rows file is never touched.
- 5Visibility, then exact check
A version this snapshot cannot see is dropped. A fingerprint can say maybe but never no to a match, so each candidate is checked exactly.
- 6The answer
What survives is the answer: no false negatives, ever, and the false positives were cheap.
Declared indexes
With no USING, a column of UUIDs, documents or MAC addresses gets a hash index, since nobody asks a range of a random UUID; anything ordered gets a B-tree. A type that cannot be indexed by the requested method is refused with the reason, never indexed approximately.
CREATE INDEX orders_customer ON orders (customer_id); -- method chosen CREATE INDEX orders_placed ON orders USING btree (placed_at); CREATE INDEX sessions_token ON sessions USING hash (token); CREATE INDEX orders_cust_day ON orders (customer_id, placed_at); -- composite CREATE INDEX IF NOT EXISTS ON orders (status); -- name derived
Kept honest
- An implicit index for every PRIMARY KEY, UNIQUE column and composite unique constraint
- Persistent on disk, paged, resident in memory or behind a cache: your choice per server
- rdb_index_check audits a table's indexes against its rows
- On a partitioned table, CREATE INDEX applies to every partition
The filter index underneath
Unindexed columns still prune their scans: zone maps at 0.25 bits per row skip ranges, and bit-sliced fingerprints test 512 rows per SIMD register. Tune it per column, or turn it off where it does not pay.
SET FILTER max_f = 24 FOR COLUMN users.email; SET FILTER indexed = off FOR TABLE audit_log;