[MDEV-31342] I_S optimization: avoid temp table Created: 2023-05-25  Updated: 2024-01-23

Status: Stalled
Project: MariaDB Server
Component/s: Information Schema
Fix Version/s: 11.5

Type: Task Priority: Major
Reporter: Sergei Golubchik Assignee: Andrew Hutchings
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Relates
relates to MDEV-31344 I_S optimization: fast status variabl... Stalled

 Description   

Currently information_schema tables work like:

  1. prepare information_schema table
    • this creates a temporary table
  2. call the information_schema implementation code
    • it sets values using Field::store() and calls schema_table_store_record() per row
    • schema_table_store_record() uses handler::ha_write_row() to store the row in he temporary table
  3. when the temporary table is filled with data, it's used in the query.

For queries like SELECT f1, f2, ... FROM INFORMATION_SCHEMA.tbl the above adds a lot of overhead. The server can recognize that case, not create a temporary table in the step 1. And modify schema_table_store_record() to send results directly to the client.

Another case when a temporary table can be avoided is when a subquery with the information schema table is used in a context implying that the result can be only one row (or an error). Like

SET @a=(SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME='xxx')


Generated at Thu Feb 08 10:23:07 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.