feat: model CI queries at the repo's configured statistics scale - #200
Open
veksen wants to merge 1 commit into
Open
feat: model CI queries at the repo's configured statistics scale#200veksen wants to merge 1 commit into
veksen wants to merge 1 commit into
Conversation
Implements Query-Doctor/Site#3119. A repo can set a statistics scale in CI settings, and nothing read it. The analyzer now passes it to the stats mode it builds, so core plans every query against that multiple of the table and index sizes. The scale rides inside the statisticsMode already posted to the Site, which stamps it on the run. A scale of 1 is left off the mode, so a repo at the default size posts exactly what it posted before. Adopts @query-doctor/core ^0.18.0, the first version whose StatisticsMode carries scale. Co-Authored-By: Claude <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: "019faaf6-f15b-7236-a55a-c049ce7300cb" }) · 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.
Implements Query-Doctor/Site#3119, the last child of the predict-at-scale epic (Query-Doctor/Site#3114). The Site side is on
feat-predict-at-scale(Query-Doctor/Site#3698).Goal
Query Doctor's homepage promises performance predicted at 10× and 1000× the data. Everything for that now exists except the step that reads the setting: the Site stores a per-repo statistics scale, the app labels a run with it, the API refuses to compare runs across a scale change, and core multiplies row counts by it. This PR is the analyzer reading the setting and using it.
What
Before: a repo could set a statistics scale in CI settings and nothing happened. Every run was planned against the current data.
After: a repo set to 10× has its CI queries planned against ten times the table and index sizes, so an index that only starts mattering at that size shows up before the table gets there. The run log says
Modeling queries at 10x the current data size. A repo left at 1× posts exactly the payload it posted before.How
Read
src/config.tsfirst.configuredStatisticsScaleis the one place that reads the setting off the relay's repo config. The read is defensive because core'sRepoConfigtype does not declarestatisticsScaleeven though the Site has sent it since Site#3115: a missing, non-numeric, or sub-1 value means the current size, so an analyzer talking to an older Site keeps working and a nonsense value never reaches the planner. The cast can go once core ships the field.Runner.determineStatsModetakes the scale and applies it to whichever mode wins its existing precedence: production stats, then a stats file, then the synthetic assumption. It is applied in one place,atScale, rather than three times inside the branches. A scale of 1 is left off the mode entirely, which keeps the posted payload byte-identical for repos that never touch the setting.Nothing else changes shape. The scale rides inside the
statisticsModethe reporter already posts, and the Site stamps it on the run (Site#3694).CiQueryOptimization.coststays a single number.@query-doctor/coremoves to^0.18.0, the first published version whoseStatisticsModecarriesscale.Tests
src/config.test.ts: the scale is read from a repo config, a config without one means 1×, and a0or a"10"is ignored.src/runner.test.ts: production stats are modeled at the configured scale, so is the synthetic assumption, and 1× or no scale leaves the mode unscaled. Written before the change; the first two failed withexpected undefined to be 10.npm run test: 374 passed across 38 files.npm run typecheck: clean.Verifying end to end
Not done here, and worth doing on a real repo once the Site branch merges: set a repo to 10×, push, and check the run header reads
modeled at 10×and the costs move. The Site side refuses to compare that first run against its 1× baseline, which is the intended re-baseline (Site#3118).