Files
codex/codex-rs/state/migrations/0064_thread_listing_indexes.sql
T
Charlie Marsh eb53da6c3a Fix thread listing migration numbering and test setup (#61730)
## Why

The thread listing index migration shares version `0063` with the session model IDs migration, and the sidebar query-plan test omits the required `included_thread_ids` field.

## What changed

- Renumber the thread listing index migration to `0064`.
- Set `included_thread_ids` to `None` in the sidebar query-plan test.

GitOrigin-RevId: 2c4c4ed52dd412fbf379ddbd2ed77324fba3b1ca
2026-11-16 03:23:10 +00:00

23 lines
1.2 KiB
SQL

-- Let attached-thread listings seek by both filters, even without planner statistics.
DROP INDEX idx_threads_attached_parent;
CREATE INDEX idx_threads_attached_parent
ON threads(attached_thread_parent_id, archived)
WHERE attached_thread_parent_id IS NOT NULL;
-- Keep the default visible chat listing in timestamp order without scanning subagents.
-- The literal source predicates match the default-source branch of push_list_threads_query.
CREATE INDEX idx_threads_interactive_created_at_ms
ON threads(archived, created_at_ms DESC, id DESC)
WHERE archived = 0 AND preview <> '' AND attached_thread_parent_id IS NULL
AND source IN ('cli', 'vscode', '{"custom":"atlas"}', '{"custom":"chatgpt"}');
CREATE INDEX idx_threads_interactive_updated_at_ms
ON threads(archived, updated_at_ms DESC, id DESC)
WHERE archived = 0 AND preview <> '' AND attached_thread_parent_id IS NULL
AND source IN ('cli', 'vscode', '{"custom":"atlas"}', '{"custom":"chatgpt"}');
CREATE INDEX idx_threads_interactive_recency_at_ms
ON threads(archived, recency_at_ms DESC, id DESC)
WHERE archived = 0 AND preview <> '' AND attached_thread_parent_id IS NULL
AND source IN ('cli', 'vscode', '{"custom":"atlas"}', '{"custom":"chatgpt"}');