Skip to content

feat(github): say which table grew when queries got more expensive - #206

Merged
veksen merged 1 commit into
mainfrom
feat-attribute-regressions-to-table-growth
Jul 31, 2026
Merged

veksen merged 1 commit into
mainfrom
feat-attribute-regressions-to-table-growth

Conversation

@veksen

@veksen veksen commented Jul 31, 2026

Copy link
Copy Markdown
Member

Goal

Stop the comment blaming a diff for the database growing. Follow-up to #201 and #205.

What

Run 019fb8fd blocked Site#3775, a pull request that changes one markdown file, on 9 cost regressions. The cause was not the diff:

project_queries   3,503 -> 6,290 rows   +80%   in the 21 hours since the baseline

All 9 read that table. The other 4 movers over threshold read oauth_tokens, which grew 28%.

After, the regression gate carries a line above its queries:

x Cost regression — 9 queries went up more than 10%, ignoring anything under a cost of 100
      Bigger tables since the baseline: project_queries +80% (3,503 -> 6,290 rows).
      A plan costs more against more rows, whatever the diff changed.

      ProjectQueriesRepository.findByProject
      apps/api/src/projects/project-queries.repository.ts:269:8 · 397,498 on the baseline, 718,215 here (+81%)

How

src/gate/table-growth.ts diffs the two runs' computedStats.reltuples and returns tables that grew at least 10%, largest first. It returns nothing when either side lacks statistics, which is the case for a run planned on assumptions.

PreviousRun gains computedStats. GET /ci/runs/latest has always returned it — the type dropped it, which is why the comment could not see the growth.

The line states the growth and stops. It does not claim the growth explains any particular query, because the comparison cannot prove that; a reader who sees project_queries +80% above nine queries that read project_queries can draw it themselves.

Tests

table-growth.test.ts covers the largest-first ordering, ignoring noise under 10%, and returning nothing without statistics. github.test.ts covers the line rendering under a fired gate and staying absent when no table grew. Full suite: 393 passing, 40 files, typecheck clean.

Not in this PR

Per-query attribution. RegressedQuery would need tableReferences, which compareRuns drops the same way it dropped tags before #202. That would let the gate soften a regression whose tables grew, rather than only explaining it.

A cost comparison sees two numbers and calls the difference a regression. On
run 019fb8fd nine queries went up on a pull request that changed one markdown
file: project_queries had grown 80% overnight, and every one of the nine reads
that table.

Both runs already carry the row counts the planner used. GET /ci/runs/latest
returns computedStats and the PreviousRun type dropped it, so the comment could
not see the growth it was blaming on the diff.

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.

6 successful checks

 Cost regression — No query got more expensive than the threshold allows
 Untested data access — No changed data-access file without a test
 New query — No new queries
 New query with index recommendation — No new query ships an index recommendation
 Schema drift — No schema changes
 High-value nudge — No index or rewrite past the threshold


More details via MCP → get_ci_run({ runId: "019fb933-180f-7f37-9582-ec9f50d73459" }) · view run · docs
3 queries read against main on assumed statistics of 10,000,000 rows per table. Sync production stats for costs measured against your real data.

@veksen
veksen merged commit 526c66c into main Jul 31, 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