AFTER — 5d337e006d940db08e0793944a28e6c0e947eba8 Linux x86_64; Node 26.13.1; same machine and local filesystem; cold OS file cache before each service call Actual ProjectionStore.getThreadRecords providerThreads-only read used before provider-session detach/release, not message.dispatch Fresh server-migrated synthetic database: 5,523 completed acknowledged tasks; 3,768 completed thread runs; 80,000 shuffled other runs, 3 KB payloads; ANALYZE. Database bytes: 390569984 Production service cold reads (milliseconds): 1: 38.233 2: 33.299 3: 40.018 4: 33.508 5: 34.696 6: 29.295 7: 27.627 8: 32.794 9: 34.675 Median: 33.508 ms Range width: 12.391 ms All nine results identical: True Same records across commits: True Returned records: [ { "id": "pt:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "appThreadId": "thread:child:0", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "status": "idle", "firstRunOrdinal": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "pendingBackgroundTasks": [], "contextUsage": null, "nativeMetadata": null, "goal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z" } ] EXPLAIN QUERY PLAN (system SQLite): [3, 0, 0, 'SEARCH orchestration_v2_projection_provider_threads USING INTEGER PRIMARY KEY (rowid=?)'] [7, 0, 0, 'LIST SUBQUERY 10'] [9, 7, 0, 'COMPOUND QUERY'] [10, 9, 0, 'LEFT-MOST SUBQUERY'] [12, 10, 0, 'SEARCH orchestration_v2_projection_provider_threads USING COVERING INDEX orchestration_v2_projection_provider_threads_thread_idx (thread_id=?)'] [22, 9, 0, 'UNION USING TEMP B-TREE'] [24, 22, 0, 'SCAN orchestration_v2_projection_provider_threads USING COVERING INDEX orchestration_v2_projection_provider_threads_owner_idx'] [29, 22, 0, 'LIST SUBQUERY 2'] [33, 29, 0, 'SEARCH owned USING COVERING INDEX orchestration_v2_projection_provider_threads_owner_idx (owner_node_id>?)'] [37, 29, 0, 'SEARCH owner USING INDEX sqlite_autoindex_orchestration_v2_projection_nodes_1 (node_id=?)'] [60, 9, 0, 'UNION USING TEMP B-TREE'] [62, 60, 0, 'SEARCH orchestration_v2_projection_provider_threads USING COVERING INDEX sqlite_autoindex_orchestration_v2_projection_provider_threads_1 (provider_thread_id=?)'] [66, 60, 0, 'LIST SUBQUERY 6'] [68, 66, 0, 'SEARCH orchestration_v2_projection_subagents USING INTEGER PRIMARY KEY (rowid=?)'] [72, 66, 0, 'LIST SUBQUERY 5'] [74, 72, 0, 'SEARCH candidate USING COVERING INDEX orchestration_v2_projection_subagents_settled_idx (thread_id=?)'] [137, 72, 0, 'CORRELATED SCALAR SUBQUERY 4'] [141, 137, 0, 'SEARCH run USING COVERING INDEX orchestration_v2_projection_runs_run_status_idx (run_id=? AND status=?)'] [205, 9, 0, 'UNION USING TEMP B-TREE'] [208, 205, 0, 'SEARCH shared USING INDEX orchestration_v2_projection_provider_threads_session_idx (provider_session_id=?)'] [212, 205, 0, 'LIST SUBQUERY 8'] [214, 212, 0, 'SCAN orchestration_v2_projection_provider_session_bindings'] [231, 205, 0, 'CORRELATED SCALAR SUBQUERY 9'] [236, 231, 0, 'SEARCH owner USING INDEX orchestration_v2_projection_subagents_provider_thread_idx (provider_thread_id=?)'] [274, 0, 0, 'USE TEMP B-TREE FOR ORDER BY'] Cold sqlite3 -readonly replay of the captured production statement (3 runs): {"id": "pt:0", "appThreadId": "thread:child:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "status": "idle", "firstRunOrdinal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z"} Memory Used: 971168 (max 1864320) bytes Number of Outstanding Allocations: 2464 (max 2685) Number of Pcache Overflow Bytes: 633096 (max 706896) bytes Largest Allocation: 87360 bytes Largest Pcache Allocation: 4368 bytes Lookaside Slots Used: 50 (max 123) Successful lookaside attempts: 190 Lookaside failures due to size: 5 Lookaside failures due to OOM: 651 Pager Heap Usage: 718840 bytes Page cache hits: 16542 Page cache misses: 165 Page cache writes: 0 Page cache spills: 0 Schema Heap Usage: 172752 bytes Statement Heap/Lookaside Usage: 18424 bytes Fullscan Steps: 5522 Sort Operations: 1 Autoindex Inserts: 0 Virtual Machine Steps: 370189 Reprepare operations: 0 Number of times run: 1 Memory used by prepared stmt: 18424 Bytes received by read(): 690138 Bytes sent to write(): 8 Read() system calls: 184 Write() system calls: 8 Bytes read from storage: 794624 Bytes written to storage: 32768 Cancelled write bytes: 0 Run Time: real 0.029 user 0.003824 sys 0.003847 {"id": "pt:0", "appThreadId": "thread:child:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "status": "idle", "firstRunOrdinal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z"} Memory Used: 971168 (max 1864320) bytes Number of Outstanding Allocations: 2464 (max 2685) Number of Pcache Overflow Bytes: 633096 (max 706896) bytes Largest Allocation: 87360 bytes Largest Pcache Allocation: 4368 bytes Lookaside Slots Used: 50 (max 123) Successful lookaside attempts: 190 Lookaside failures due to size: 5 Lookaside failures due to OOM: 651 Pager Heap Usage: 718840 bytes Page cache hits: 16542 Page cache misses: 165 Page cache writes: 0 Page cache spills: 0 Schema Heap Usage: 172752 bytes Statement Heap/Lookaside Usage: 18424 bytes Fullscan Steps: 5522 Sort Operations: 1 Autoindex Inserts: 0 Virtual Machine Steps: 370189 Reprepare operations: 0 Number of times run: 1 Memory used by prepared stmt: 18424 Bytes received by read(): 690138 Bytes sent to write(): 8 Read() system calls: 184 Write() system calls: 8 Bytes read from storage: 794624 Bytes written to storage: 28672 Cancelled write bytes: 28672 Run Time: real 0.028 user 0.005189 sys 0.001823 {"id": "pt:0", "appThreadId": "thread:child:0", "driver": "codex", "providerInstanceId": "codex", "providerSessionId": "session:shared", "ownerNodeId": null, "nativeThreadRef": null, "nativeConversationHeadRef": null, "lastRunOrdinal": null, "handoffIds": [], "forkedFrom": null, "status": "idle", "firstRunOrdinal": null, "createdAt": "2026-01-01T00:00:00.000Z", "updatedAt": "2026-01-01T00:00:00.000Z"} Memory Used: 971168 (max 1864320) bytes Number of Outstanding Allocations: 2464 (max 2685) Number of Pcache Overflow Bytes: 633096 (max 706896) bytes Largest Allocation: 87360 bytes Largest Pcache Allocation: 4368 bytes Lookaside Slots Used: 50 (max 123) Successful lookaside attempts: 190 Lookaside failures due to size: 5 Lookaside failures due to OOM: 651 Pager Heap Usage: 718840 bytes Page cache hits: 16542 Page cache misses: 165 Page cache writes: 0 Page cache spills: 0 Schema Heap Usage: 172752 bytes Statement Heap/Lookaside Usage: 18424 bytes Fullscan Steps: 5522 Sort Operations: 1 Autoindex Inserts: 0 Virtual Machine Steps: 370189 Reprepare operations: 0 Number of times run: 1 Memory used by prepared stmt: 18424 Bytes received by read(): 690138 Bytes sent to write(): 8 Read() system calls: 184 Write() system calls: 8 Bytes read from storage: 794624 Bytes written to storage: 28672 Cancelled write bytes: 28672 Run Time: real 0.026 user 0.006579 sys 0.000000