Self-test
Check your understanding
Self-test8 questions
An index on (created_at, customer_id) made a customer's latest-orders query over 400 times slower than (customer_id, created_at). Explain using how a B-tree is sorted.
Why did count(*) for a value matching 95% of rows still use the index, while sum(amount) for the same rows did a sequential scan?
Why is a B-tree on a low-cardinality column like status much smaller in Postgres 13+ than you might expect?
A covering index scan touched 19,252 pages right after an UPDATE and 161 after VACUUM. What changed?
Why could an index on email not answer WHERE lower(email) = ..., and what fixed it?
Five extra indexes made a bulk insert 8 times slower. How do you find indexes that are pure cost?
In EXPLAIN ANALYZE output, which single signal most often reveals a bad plan?
- Design question
Design the indexes for an orders table queried by: one customer's recent orders, all pending orders, and a nightly report by date range. Justify each, including what you would not index.