perf(database): drop unused TaskRun(scheduleId, createdAt) index#3706
Conversation
The schedule list view reads from ClickHouse, so this composite index served no Prisma query while still being maintained on every TaskRun INSERT/UPDATE.
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
💤 Files with no reviewable changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (20)
🧰 Additional context used📓 Path-based instructions (1)internal-packages/database/**/prisma/migrations/*/*.sql📄 CodeRabbit inference engine (internal-packages/database/CLAUDE.md)
Files:
🧠 Learnings (3)📚 Learning: 2026-02-03T18:48:31.790ZApplied to files:
📚 Learning: 2026-03-22T13:49:20.068ZApplied to files:
📚 Learning: 2026-05-14T14:54:39.095ZApplied to files:
🔇 Additional comments (2)
WalkthroughThis PR optimizes the TaskRun table's database indexes. It removes a composite index on (scheduleId, createdAt) that was designed for schedule list queries but is no longer needed since the schedule view now reads from ClickHouse instead of Postgres. The change replaces it with five new indexes optimized for batch queries and tag-based searches: a Gin index on runTags, composite indexes for batch/environment queries, a Brin index for time-based queries, and a composite index on status/environment/time/id. The update spans documentation, a SQL migration, and the Prisma schema. Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Drops the unused composite Postgres index
TaskRun_scheduleId_createdAt_idx. The schedule list view reads from ClickHouse, so this index served no Prisma query while still being maintained on everyTaskRunINSERT/UPDATE. Removing it reduces write amplification on the primary database.Sibling to the prior drop of
TaskRun_scheduleId_idxand the earlier removal of theTaskRun.scheduleIdforeign key — all stemming from migrating schedule-aware reads to ClickHouse.Verification
pg_stat_user_indexesforTaskRunover multiple hours — zero scans against this index.TaskRun.scheduleId— none found. All schedule-aware listing routes throughclickhouseRunsRepository.