[MDEV-27294] Implement EXPLAIN for SHOW Created: 2019-09-30  Updated: 2021-12-17

Status: Open
Project: MariaDB Server
Component/s: Admin statements, Information Schema, Optimizer
Fix Version/s: None

Type: Task Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Unassigned
Resolution: Unresolved Votes: 1
Labels: statement_explain, statement_show

Issue Links:
Relates
relates to MDEV-30340 Implement EXPLAIN for DDL such as ALT... Open

 Description   

EXPLAIN currently supports SELECT queries that target information_schema tables. For example, these queries are valid:

EXPLAIN SELECT * FROM information_schema.TABLES 
   WHERE TABLE_SCHEMA='db1';
 
EXPLAIN SELECT * FROM information_schema.TRIGGERS 
   WHERE EVENT_OBJECT_SCHEMA='db1';
 
EXPLAIN SELECT * FROM information_schema.GLOBAL_VARIABLES 
   WHERE VARIABLE_NAME='character_set_server';

Sometimes this functionality is very important, because innocent-looking SELECT queries that target information_schema tables can actually cause serious performance issues. For example, see here:

https://dev.mysql.com/doc/refman/5.7/en/information-schema-optimization.html

However, one problem is that if we convert the above SELECT queries to their equivalent SHOW queries, then EXPLAIN fails. For example:

EXPLAIN SHOW TABLE STATUS 
   FROM db1;
 
EXPLAIN SHOW TRIGGERS 
   FROM db1;
 
EXPLAIN SHOW GLOBAL VARIABLES 
   WHERE VARIABLE_NAME='character_set_server';

Some of these SHOW queries can probably have similar problems as SELECT queries that target information_schema tables.

If so, then wouldn't it make sense to implement EXPLAIN for them as well?


Generated at Thu Feb 08 09:51:50 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.