Skip to content

fix(data-warehouse): improve SQL editor typing latency#8

Open
lordspline wants to merge 1 commit into
masterfrom
capy/fix-sql-editor-typing-latency
Open

fix(data-warehouse): improve SQL editor typing latency#8
lordspline wants to merge 1 commit into
masterfrom
capy/fix-sql-editor-typing-latency

Conversation

@lordspline

@lordspline lordspline commented Jun 17, 2026

Copy link
Copy Markdown

Problem

Large SQL editor documents could make typing feel frozen because active-query decorations synchronously re-parsed the current SQL document after every content change. This addresses PostHog#60974.

Changes

  • Coalesce active-query decoration refreshes behind the existing short scheduling path used for cursor-driven decoration updates.
  • Keep query input, draft state, URL state, save/run behavior, and metadata parsing independent from the visual decoration schedule.
  • Add a deterministic large-SQL benchmark plus focused unit coverage for the decoration scheduling behavior.

How did you test this code?

  • Agent-run benchmark: SQL_EDITOR_LATENCY_BENCHMARK=1 hogli test frontend/src/scenes/data-warehouse/editor/sqlEditorLatency.benchmark.test.ts
    • 32,855-byte generated SQL document on 16 vCPU AMD EPYC 9254 / 31 GiB VM
    • Before: input-ready median 596.2 ms, p95 699.8 ms across 5 benchmark runs
    • After: input-ready median 1.7 ms, p95 2.8 ms across 5 benchmark runs
  • Agent-run tests: hogli test frontend/src/scenes/data-warehouse/editor/sqlEditorLogic.test.ts frontend/src/scenes/data-warehouse/editor/multiQueryUtils.test.ts
  • Agent-run formatting: pnpm --filter=@posthog/frontend format
  • Agent-run typecheck: pnpm --filter=@posthog/frontend typescript:check
  • Agent browser verification covered normal and large-query typing, paste, undo/redo, tab switching, running, and saving.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No docs update needed; this is a SQL editor interaction-performance fix.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Capy reproduced the issue with a deterministic large SQL document and profiled before changing code. The dominant hot path was HogQL parser/WASM work from active-query decoration refreshes, so the fix moves only that visual decoration work off the keypress-ready path instead of debouncing the editor state itself.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

Co-authored-by: capy-ai[bot] <230910855+capy-ai[bot]@users.noreply.github.com>
@lordspline lordspline added the capy Generated by capy.ai label Jun 17, 2026 — with Capy AI
@capy-ai capy-ai Bot changed the title fix(data-warehouse): improve SQL editor typing latency by debouncing active-query parsing fix(data-warehouse): improve SQL editor typing latency Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capy Generated by capy.ai

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant