Skip to content

feat(grid): say how many rows there are, not just that some are missing (#402) - #631

Merged
EVWorth merged 1 commit into
mainfrom
feat/results-row-count
Sep 11, 2026
Merged

EVWorth merged 1 commit into
mainfrom
feat/results-row-count

Conversation

@EVWorth

@EVWorth EVWorth commented Sep 11, 2026

Copy link
Copy Markdown
Owner

Stacked on #630.

FR-3.1.7. A truncated result said "truncated to 1000 rows" and nothing more, so 1000 of 1,200 and 1000 of 12,000,000 looked identical — and they call for different responses: scroll on, or rewrite the query.

Two answers, because they cost different amounts.

The estimate is free. information_schema.TABLES already holds the engine's own row count, and for the common SELECT * FROM t that is the answer, so it's fetched without being asked for. It's reported as "approximately": InnoDB samples TABLE_ROWS from the index and can be wide of the mark, and presenting it as exact would make a later exact count look like a bug when the two disagree. A WHERE clause disqualifies it — TABLE_ROWS answers "how big is the table", which stops being the question the moment the query filters.

The exact count is a full scan, so it only runs when asked. It counts through the user's own statement, wrapped as a named derived table, rather than counting the table — a join, a GROUP BY or a DISTINCT all return a different number from the table they read.

Statements that cannot legally be a subquery are not counted at all rather than counted wrongly: SHOW, DESCRIBE, EXPLAIN, CALL, USE are rejected by the server when wrapped, as are FOR UPDATE, LOCK IN SHARE MODE and anything carrying INTO. The banner says so instead of offering a button that fails. A count that does fail says so, rather than showing a number.

Verification

2329 unit + 331 browser tests. 20 new unit tests on the planner, 7 browser tests on the banner. Both generated statement shapes verified against live MySQL 8.0.46 and MariaDB 11.

Closes #402

🤖 Generated with Claude Code

@EVWorth
EVWorth changed the base branch from test/memory-guard-floor to main September 11, 2026 05:16
FR-3.1.7. A truncated result said "truncated to 1000 rows" and nothing more,
so 1000 of 1,200 and 1000 of 12,000,000 looked identical — and they call for
different responses: scroll on, or rewrite the query (#402).

Two answers, because they cost different amounts.

The estimate is free. `information_schema.TABLES` already holds the engine's
own row count, and for the common `SELECT * FROM t` that is the answer, so it
is fetched without being asked for. It is reported as "approximately": InnoDB
samples TABLE_ROWS from the index and can be wide of the mark, and presenting
it as exact would make a later exact count look like a bug when the two
disagree. A WHERE clause disqualifies it — TABLE_ROWS answers "how big is the
table", which stops being the question the moment the query filters.

The exact count is a full scan, so it only runs when asked. It counts through
the user's own statement, wrapped as a named derived table, rather than
counting the table — a join, a GROUP BY or a DISTINCT all return a different
number from the table they read.

Statements that cannot legally be a subquery are not counted at all rather
than counted wrongly: SHOW, DESCRIBE, EXPLAIN, CALL and USE are rejected by
the server when wrapped, as are FOR UPDATE, LOCK IN SHARE MODE and anything
carrying INTO. The banner says so instead of offering a button that fails. A
count that does fail says so, rather than showing a number.

Both statement shapes verified against MySQL 8.0.46 and MariaDB 11.

Co-Authored-By: Claude Opus 5 <[email protected]>
@EVWorth
EVWorth force-pushed the feat/results-row-count branch from 54ae06d to 4b19f10 Compare September 11, 2026 05:26
@EVWorth
EVWorth merged commit a35beb7 into main Sep 11, 2026
12 checks passed
@EVWorth
EVWorth deleted the feat/results-row-count branch September 11, 2026 05:29
@EVWorth EVWorth mentioned this pull request Sep 11, 2026
48 tasks
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.

[P1] [doc-drift] FR-3.1.7 row count — no exact or estimated count

1 participant