Open History to see the last commit
1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/sql/SqlClient";
3
4/**
5 * Pagination orders turns by the stable keyset (requested_at, turn_id); the
6 * pre-existing (thread_id, requested_at) index cannot serve the tiebreak order,
7 * forcing a temp B-tree over all of a thread's turns before the page LIMIT
8 * applies.
9 */
10export default Effect.gen(function* () {
11 const sql = yield* SqlClient.SqlClient;
12 yield* sql`
13 CREATE INDEX IF NOT EXISTS idx_projection_turns_thread_keyset
14 ON projection_turns(thread_id, requested_at, turn_id)
15 `;
16});