# fix\(server\): stop maintaining the unused event correlation index · PR \#23171 · pingdotgg/t3code

[View on GitCafe](https://git.cafe/pingdotgg/t3code/pull/23171)

Repository: [pingdotgg/t3code](https://git.cafe/pingdotgg/t3code)

Visibility: public

State: open

Source repository: pingdotgg/t3code

Source branch: fix/issue-20534

Target branch: main

Head commit: 4faeac514204f78c537380ba5a8b7ae2401ce83c

[Discussion and reviews](https://git.cafe/pingdotgg/t3code/pull/23171)

[Commits](https://git.cafe/pingdotgg/t3code/pull/23171/commits?format=markdown)

[Files changed](https://git.cafe/pingdotgg/t3code/pull/23171/diffs?format=markdown)

## Description

---

## Problem

Every event insert maintains an unused correlation-ID index. On main, starting the real dev server and inspecting its isolated database with `dbstat` confirms the index remains; a larger read-only database has 2,211,840 bytes in it for 73,876 events. No server query filters or orders by that column. See [#20534](https://github.com/pingdotgg/t3code/issues/20534).

## Change

Add migration 68 to drop only `idx_orch_events_correlation_id`. Preserve the correlation column, its values, and all other event indexes, including the agent-stream index required by legacy import. Add one upgrade regression test and update the existing migration-list expectations.

## Scope and approval

Fixes #20534
GitCafe: https://git.cafe/pingdotgg/t3code/issues/20534
Triaged bug via the automated issue flow. This focused server performance fix removes an unused index without changing product behavior, contracts, or client code.

## Verification

- Red: on main plus the regression test, `vp test run src/persistence/Migrations.test.ts` failed on the assertion that the unused index must be absent (1 failed, 7 passed).
- Green: 33 focused tests passed across `Migrations.test.ts`, `reconcileV2PreviewMigration.test.ts`, `OrchestrationEventStore.test.ts`, `OrchestrationEventStore.sequence.test.ts`, `initializeV2Database.test.ts`, `orchestration-v2/legacy/LegacyV1ThreadImporter.test.ts`, and `orchestration-v2/legacy/LegacyV1Cutover.integration.test.ts`. The upgrade test checks that correlation values and required indexes survive.
- After merging current main with a merge commit, reran the same seven files: 33 passed at [4faeac5142](https://git.cafe/pingdotgg/t3code/commit/4faeac514204f78c537380ba5a8b7ae2401ce83c).
- Targeted lint and the server package typecheck passed. No repo-wide checks.
- Runtime: `vp run dev --home-dir /tmp/issue20534-canonical` upgraded a canonical database from migration 67 to 68. The paired real web client loaded and created a thread. The index went from present (4,096 bytes on the empty fixture) to absent; four real events retained correlation values and all other event indexes remained. [Runtime transcript](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/17571b7b9ed0571e/issue20534-runtime.txt).
- [Audited evidence index](https://gh-file-drop-api-prod-mi5fy3sowv63ufte.pinglabs.workers.dev/f/4fbfec8fbdb133ef/issue20534-evidence-index.md). Visual matrix: empty; no render paths changed. Server-only proof is the regression test plus runtime transcript. No native-client behavior was changed.
- The populated reproduction snapshot has local-fork migration records, so the upstream runtime upgrade used a separate canonical fixture. A large populated canonical database was not timed. Schema-copy insert timings were noisy; no percentage speedup is claimed. Dropping the index frees database pages for reuse, rather than shrinking the file automatically.

Implemented with Claude Opus 5.5 through the Claude Code harness; triaged and reviewed with GPT-6.1-Sol through the Codex harness and Claude Opus 5.5 through Claude Code.


<!-- gc2-pull-create:9500839b41b2d5af5baaaba1dafb57853940887fc327032aad4ff726953d6aba -->
