MDEV-31342: Optimize INFORMATION_SCHEMA.TABLES queries to skip temp table writes#5345
MDEV-31342: Optimize INFORMATION_SCHEMA.TABLES queries to skip temp table writes#5345itzanway wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a fast-path optimization for simple Information Schema queries to bypass temporary table materialization and stream results directly to the client. While the optimization is a great performance improvement, several critical issues were identified in the review. First, the new in_exec_inner flag is uninitialized and never set during execution, which would completely disable the fast path. Second, the query qualification logic fails to check for OFFSET or SQL_CALC_FOUND_ROWS, potentially leading to incorrect query results. Finally, the fast-path state is not properly reset for standard prepared statements, causing subsequent executions to silently fall back to the slow path.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
85dda65 to
fd11732
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Thank you for working on this. This is a preliminary review.
Please fix the buildbot failures:
main.mdev_31342 w18 [ fail ]
Test ended at 2026-07-06 19:27:46
CURRENT_TEST: main.mdev_31342
--- /home/buildbot/amd64-ubuntu-2204-debug-ps/build/mysql-test/main/mdev_31342.result 2026-07-06 19:11:39.000000000 +0000
+++ /home/buildbot/amd64-ubuntu-2204-debug-ps/build/mysql-test/main/mdev_31342.reject 2026-07-06 19:27:46.237451975 +0000
@@ -81,7 +81,7 @@
user
SHOW SESSION STATUS LIKE 'Created_tmp_tables';
Variable_name Value
-Created_tmp_tables 1
+Created_tmp_tables 3
#
# Verify: ORDER BY uses fallback
#
@@ -95,7 +95,7 @@
db
SHOW SESSION STATUS LIKE 'Created_tmp_tables';
Variable_name Value
-Created_tmp_tables 1
+Created_tmp_tables 3
#
# EXPLAIN shows no filesort for fast-path query
#
Also, some suggestions below.
janlindstrom
left a comment
There was a problem hiding this comment.
There is still test failure and added some comments.
9b3c12b to
84e7f2c
Compare
gkodinov
left a comment
There was a problem hiding this comment.
many more white-space only changes: please check your editor. I also stand by my previous comments on the testing.
1674652 to
fc14837
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Please fix the white-space only changes.
Fixed in the latest commit — stripped all trailing whitespace from sql/sql_show.cc. These were pre-existing in upstream/main (37 lines across the file, none in code we wrote), but since they appear in context of our diff hunks, they show up as our changes. Removed them all for cleanliness. |
janlindstrom
left a comment
There was a problem hiding this comment.
- There is increased amount of white space changes, please revert them.
- Test cases still do not contain requested EXPLAIN for EVERY query so that you can see is fast path used and cases where it is not
- There is still failing tests on CI
Do not do this please, no changes outside necessary code additions/changes. |
49685ee to
c68991b
Compare
gkodinov
left a comment
There was a problem hiding this comment.
Please fix the windows failure. Also, please consider squashing the commits at some point.
b401e83 to
da472fe
Compare
|
please check what you've pushed - 473 file changes - did this get squashed with a merge commit? |
4348bff to
e4a1f10
Compare
gkodinov
left a comment
There was a problem hiding this comment.
LGTM. Thanks for working on this. Please stand by for the final review.
…able writes For simple single-schema SELECT queries on information_schema.tables, bypass ha_write_tmp_row() and stream rows directly via the protocol. Add EXPLAIN is_fast_path visibility and MTR coverage, including Windows EXPLAIN casing normalization.
aa30b07 to
26843b2
Compare
For simple single-schema SELECT queries on information_schema.tables,
bypass the internal temporary table write (ha_write_tmp_row()) and
stream rows directly to the client via the protocol layer.
Eligible queries are detected by is_simple_is_query(): single table,
no UNION/subquery/ORDER BY/GROUP BY/DISTINCT/aggregates, specific
schema lookup value (has_db_lookup_value()), no SELECT *.
Guards: join->table_count==1, SCH_TABLES only, SKIP_OPEN_TABLE,
has_db_lookup_value(), no views, const_item() on LIMIT,
fp_state reset on re-execution.
Performance: fast path flat ~31ms vs legacy path growing linearly
to ~78ms at 2000 tables.
Test coverage: simple SELECT, prepared statements (re-execution),
stored procedure, view (fallback), trigger, WHERE conditions,
ORDER BY/GROUP BY/DISTINCT fallbacks, EXPLAIN FORMAT=JSON.