fix: skip non-DML statements when pushing queries#179
Merged
Conversation
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>
There was a problem hiding this comment.
Query Doctor Analysis
3 queries analyzed
0 regressed · 0 improved · 0 new · 0 removed
2 pre-existing issues
SELECT "guests"."id", "guests"."session_id", "guests"."username", "guests"."avatar_path", "guests"."color", "guests"."side", "guests"."audio_recording_path", "guests"."audio_recording_public", "gue...
indexassets(event_id, inserted_at desc)
cost 31,003,449 → 1,498 (100% reduction)SELECT * FROM guest_ip_addresses WHERE ip_address = '127.0.0.1';
indexguest_ip_addresses(ip_address)
cost 154,402 → 8 (100% reduction)
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,
COPYfrom 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/VACUUMnever 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.tsfirst:analyze()already receives core's AST-derivedstatementTypeand used it only forisSelectQuery— it now stays on the instance.src/remote/api-client.tsthen dropsstatementType === "other"at both push sites (polled batches and optimizer results). Two decisions: queries whose analysis was skipped (oversized) or failed have nostatementTypeand are pushed anyway — fail open rather than silently losing real queries; andMERGEis a known gap (core's map classifiesMergeStmtas"other") until core'sSTATEMENT_TYPE_MAPlearns it — noted in the comment, not worth a core release on its own.Tests
recent-query.test.ts:SELECTkeepsstatementType: "select";CREATE INDEXandCOPYclassify as"other"; oversized queries skip analysis and carry nostatementType. Full suite 310/310.