Skip to main content

max / makenotwork

486 B · 8 lines History Blame Raw
1 -- Covering index for the version listing's `WHERE item_id = $1 ORDER BY
2 -- created_at DESC` access pattern (db::versions::get_versions / get_versions_
3 -- paginated). The existing `idx_versions_item_id` is single-column, so the
4 -- order-by fell back to an in-memory sort. Bounded by the per-item version cap,
5 -- so this is a minor win, but it removes the sort on the item-page render path.
6 CREATE INDEX IF NOT EXISTS idx_versions_item_created
7 ON versions(item_id, created_at DESC);
8