Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

111_SupersededRunAttemptIndex.ts

14 lines588 Bytes

1import * as Effect from "effect/Effect";
2import * as SqlClient from "effect/sql/SqlClient";
3​
4export default Effect.gen(function* () {
5 const sql = yield* SqlClient.SqlClient;
6​
7 // Opening a thread's history looks up its few superseded attempts. Without this index that
8 // reads every attempt row of the thread, which is slow on a long thread with a cold cache.
9 yield* sql`
10 CREATE INDEX IF NOT EXISTS orchestration_v2_projection_run_attempts_superseded_idx
11 ON orchestration_v2_projection_run_attempts(thread_id, run_id, root_node_id)
12 WHERE status = 'superseded'
13 `;
14});