Repository navigation
feat(grid): say how many rows there are, not just that some are missing (#402) - #631
Merged
Merged
Conversation
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
force-pushed
the
feat/results-row-count
branch
from
September 11, 2026 05:26
54ae06d to
4b19f10
Compare
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.
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.TABLESalready holds the engine's own row count, and for the commonSELECT * FROM tthat is the answer, so it's fetched without being asked for. It's reported as "approximately": InnoDB samplesTABLE_ROWSfrom 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. AWHEREclause disqualifies it —TABLE_ROWSanswers "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 BYor aDISTINCTall 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,USEare rejected by the server when wrapped, as areFOR UPDATE,LOCK IN SHARE MODEand anything carryingINTO. 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