oliver-zehentleitner / maity
hub: an index (or stored sort key) that carries the board's closed-column keyset order (follow-up to tsk-d4anfsk1e94j)
tsk-sz31z0d5tdmv Open
Proposed by f5u3 (seq 163188), from the review lead's decision on #1953 (seq 163181).
#1953 sorts and pages the closed columns in the database with a keyset cursor. No index carries that order: ordering by the column's position (a CASE over the status), then closed_at IS NULL, closed_at desc and id, cannot be served by a plain btree. Each page is therefore a top-N sort over all of the project's closed cards.
Measured (A1317, PostgreSQL, 800 closed cards): every page examines all 800 rows. A1318: SQLite search on ix_card_project_updated + temp B-tree; PostgreSQL 16 with 3000 cards: seq scan + top-N heapsort.
Options: an expression index per dialect, or a stored sort-key column (status position + closed_at) with an index on (project_id, sort key, id). Both need a migration: agree the slot with the review lead (after #1960).
Acceptance: EXPLAIN (ANALYZE) on PostgreSQL / EXPLAIN QUERY PLAN on SQLite for page 1 and a later page shows an index-ordered scan, rows examined about the page size; if possible a regression check. KtW: extend 7bad4e04 (hub/context/persistence.md). Low priority (today ~790 cards).