Skip to content

fix(cli): stop large sql blocks stalling db reset (CLI-2469) - #6697

Merged
7ttp merged 3 commits into
developfrom
7ttp/cli-2469-slow-seeding-when-having-a-large-seed-file-and-an-anonymous
Sep 23, 2026
Merged

7ttp merged 3 commits into
developfrom
7ttp/cli-2469-slow-seeding-when-having-a-large-seed-file-and-an-anonymous

Conversation

@7ttp

@7ttp 7ttp commented Sep 21, 2026 •

Copy link
Copy Markdown
Member

TL;DR

fixes db reset stalling on a seed with a large DO $$ block or /* */ comment.

prob

the statement splitter built each statement one character at a time, and on every character inside a $$ body or block comment it sliced the tail of that string.

in bun each slice copies the whole statement so far
so splitting grew quadratically and a 1 MB DO $$ block took about 15 seconds. seeds, migrations and db push all go through this splitter...

sol

tracking start and end offsets and slicing the original input instead,
so the split stays linear and the same 1 MB block takes about 40 ms. the split output is unchanged....

ref:

@7ttp 7ttp self-assigned this Sep 21, 2026
@7ttp
7ttp requested a review from a team as a code owner September 21, 2026 23:45

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 AI Review

The offset-based rewrite preserves splitter behavior and removes the identified quadratic accumulation path. Both Claude findings are confirmed as nits: the performance test relies on Vitest's implicit timeout, and the non-obvious offset/performance invariant is undocumented. Codex reported no findings, and no correctness or security defects were found.

Findings

Severity Location Category Sources Claim
⚪ NIT apps/cli/src/command-internal/sql-split.unit.test.ts:164 test-coverage claude The performance regression test relies on Vitest's implicit default timeout instead of declaring its intended performance bound.
⚪ NIT apps/cli/src/command-internal/sql-split.ts:242 maintainability claude The code does not document that slicing by start/end offsets avoids quadratic accumulation and that state-held offsets remain relative to the current token.

Stats

Claude findings: 2 · Codex findings: 0 · Confirmed: 2 · Refuted: 0 · Uncertain: 0


Models: claude-opus-5 + gpt-5.6-sol · Trigger: auto · Workflow run

This review runs once per PR. A maintainer can request another with a /ai-review comment.

Comment thread apps/cli/src/command-internal/sql-split.unit.test.ts
Comment thread apps/cli/src/command-internal/sql-split.ts

@jgoux jgoux left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cross-review with Claude Fable reached consensus after two rounds: no actionable findings introduced by this PR. Token-relative offsets, Unicode iteration, statement boundaries, and EOF behavior are preserved. No inline findings remain.

Validation: all 59 splitter assertions passed in an isolated Bun harness (test-runner import adapted from Vitest to bun:test); 20,000 generated SQL/Unicode inputs matched the base across all four exports; direct Bun measurements confirmed the large-block speedup. The normal local package test command was blocked by dependency setup. The PR CI checks are passing. The added tests verify large-input correctness; a durable automated performance bound was not established.

@7ttp
7ttp added this pull request to the merge queue Sep 23, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Sep 23, 2026
@7ttp
7ttp enabled auto-merge September 23, 2026 09:25
@7ttp
7ttp added this pull request to the merge queue Sep 23, 2026
Merged via the queue into develop with commit fd662d1 Sep 23, 2026
32 of 34 checks passed
@7ttp
7ttp deleted the 7ttp/cli-2469-slow-seeding-when-having-a-large-seed-file-and-an-anonymous branch September 23, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Slow seeding when having a large seed file and an anonymous block.

2 participants