Skip to content

feat: model CI queries at the repo's configured statistics scale - #200

Open
veksen wants to merge 1 commit into
mainfrom
feat-statistics-scale
Open

feat: model CI queries at the repo's configured statistics scale#200
veksen wants to merge 1 commit into
mainfrom
feat-statistics-scale

Conversation

@veksen

@veksen veksen commented Jul 28, 2026

Copy link
Copy Markdown
Member

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.ts first. configuredStatisticsScale is the one place that reads the setting off the relay's repo config. The read is defensive because core's RepoConfig type does not declare statisticsScale even 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.determineStatsMode takes 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 statisticsMode the reporter already posts, and the Site stamps it on the run (Site#3694). CiQueryOptimization.cost stays a single number.

@query-doctor/core moves to ^0.18.0, the first published version whose StatisticsMode carries scale.

Tests

src/config.test.ts: the scale is read from a repo config, a config without one means 1×, and a 0 or 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 with expected 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).

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>

@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: "019faaf6-f15b-7236-a55a-c049ce7300cb" }) · view run · docs

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