Get the multicolumn index column order right
In a composite index, column order decides whether a range query can use it. Ordering for the range predicate turns a sort-heavy scan into a clean index range scan, 829 block reads drop to a handful.
Problem
What you're actually looking at
The symptom as it shows up on a real server.
A B-tree on (a, b) is sorted by a, then b. A query with a range on one column and an order-by on another only benefits if the index columns are in the order the query can consume, otherwise PostgreSQL scans wide and sorts.
Meridian queries recent bookings with a time-range filter and ordering. With the composite index columns in the wrong order the planner scans broadly and sorts the result instead of walking the index in order.
Simple terms
A B-tree index on (a, b) is sorted by a first, then by b within each a, like a contact list ordered by last name, then first name. That order decides what the index can do: a query that filters a range on one column and sorts by another only benefits if the columns line up with how the query reads them. Get the order wrong and PostgreSQL scans wide and sorts the result instead of walking the index in order.
Full runbook for this incident
- The full identify checklist, the exact signals that tell you it's this incident
- Every diagnostic query; lab output is attached only to the steps we actually captured
- The resolution path and the pitfalls that make it worse
- Mitigation steps to stop it recurring, plus a verify-you're-done query
Card required. Cancel before day 7 and you are not charged.
More in this category
Other Indexing runbooks
Neighbouring incidents that share the same diagnostic surface.
Need the full procedure?
Pro runbooks finish the incident path
Free runbooks teach the shape. Pro opens the full step transcript, edge cases, and prevention depth.