Skip to content

fix: skip non-DML statements when pushing queries#179

Merged
veksen merged 1 commit into
mainfrom
fix-skip-non-dml-push
Jul 15, 2026
Merged

fix: skip non-DML statements when pushing queries#179
veksen merged 1 commit into
mainfrom
fix-skip-non-dml-push

Conversation

@veksen

@veksen veksen commented Jul 15, 2026

Copy link
Copy Markdown
Member

Goal

Stop the uncovered-runtime-query alert spam on migration days (Query-Doctor/Site#3578): a persistent session watching a database shipped every statement pg_stat_statements retained — migration DDL, COPY from dumps/seeds — into the project's query catalog, where each one fired a "no CI coverage" alert it can never resolve. The 2026-07-14 deploy produced 16 such alerts from one migration.

What

Before: everything sampled from pg_stat_statements was pushed to the API.
After: only DML is pushed. CREATE/DROP/ALTER/COPY/VACUUM never leave the analyzer, so they no longer appear in the dashboard query catalog or trigger alerts. App queries (SELECT/INSERT/UPDATE/DELETE) are unaffected.

How

Read src/sql/recent-query.ts first: analyze() already receives core's AST-derived statementType and used it only for isSelectQuery — it now stays on the instance. src/remote/api-client.ts then drops statementType === "other" at both push sites (polled batches and optimizer results). Two decisions: queries whose analysis was skipped (oversized) or failed have no statementType and are pushed anyway — fail open rather than silently losing real queries; and MERGE is a known gap (core's map classifies MergeStmt as "other") until core's STATEMENT_TYPE_MAP learns it — noted in the comment, not worth a core release on its own.

Tests

recent-query.test.ts: SELECT keeps statementType: "select"; CREATE INDEX and COPY classify as "other"; oversized queries skip analysis and carry no statementType. Full suite 310/310.

pg_stat_statements retains everything the database executed, so migration
DDL and COPY from dumps landed in the project's query catalog and fired
unfixable "no CI coverage" alerts (Query-Doctor/Site#3578). Keep the
already-computed statementType on RecentQuery and drop "other" at both
push sites; analysis-skipped queries still push (fail open).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Query Doctor Analysis

3 queries analyzed

0 regressed · 0 improved · 0 new · 0 removed

2 pre-existing issues

Using assumed statistics (10000000 rows/table). For better results, sync production stats.

More detail → get_ci_run({ runId: "019f63d5-55c6-744a-bbba-a65b995f9419" }) · view run · docs

@veksen veksen merged commit 80af5fb into main Jul 15, 2026
6 checks passed
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.

1 participant