perf: denormalize step_count and remove labels JSON fallback#132
Conversation
#124: getRun/getRuns no longer LEFT JOIN durably_steps for step_count. Instead, step_count is a denormalized column on durably_runs, incremented atomically in persistStep alongside current_step_index. This eliminates the JOIN + COUNT + GROUP BY overhead on every run query. Also removed the labels JSON fallback (OR with json_extract/JSONB ->>) from getRuns label filtering. The indexed durably_run_labels table is the sole source of truth — the JSON column remains for backwards-compat reads but is no longer queried for filtering. #131 (partial): Removed SqlBool import and simplified rowToRun signature (no more step_count override). Migration consolidated into v1 (no backward compatibility needed). Closes #124 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughdurably_runs テーブルに step_count カラムを追加し、スキーマを拡張しました。ストレージレイヤーで step_count を初期化・更新するロジックを追加し、ステップカウント取得時の左結合クエリを削除しました。 Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 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)
📝 Coding Plan
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 |
The field only counts completed steps (not failed/cancelled), so the name should be precise. No backward compatibility needed. Renamed across: schema, migrations, storage, Run type, tests, examples, docs, and changelog. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary
#124: Remove LEFT JOIN from getRun/getRuns
Before: Every
getRun()/getRuns()didLEFT JOIN durably_steps + COUNT + GROUP BYto computestepCount. WithpreserveSteps: false(default), steps are deleted on terminal state, so this JOIN was paying cost for data that usually doesn't exist.After:
step_countis a denormalized column ondurably_runs, incremented atomically inpersistStepalongsidecurrent_step_index.getRun/getRunsis now a simpleSELECT * FROM durably_runs— no JOIN, no GROUP BY, no COUNT.Labels JSON fallback removed
The
getRunslabel filter had an OR clause:EXISTS (indexed table) OR json_extract(...). The JSON fallback was for "atomicity safety" but the indexed table is always populated in the same transaction as the run. Removed the fallback — cleaner query plan, indexed table is sole source of truth.Changes
schema.tsstep_count: numberto RunsTablemigrations.tsstep_countcolumn (DEFAULT 0) to v1storage.tspersistStep: incrementstep_countviasql\step_count + 1``storage.tsgetRun/getRuns: simple SELECT, no JOINstorage.tsgetRunslabels: remove JSON fallback, EXISTS onlystorage.tsrowToRun: readstep_countdirectly from rowstorage.tsSqlBoolimportmigration-consolidated.test.tsstep_countcolumn existsCloses #124
🤖 Generated with Claude Code
Summary by CodeRabbit
リリースノート
新機能
テスト