Enhancement
The current Plan Replayer implementation only supports dumping one SQL record at a time, and we could extend it to support multiple SQL records, for example:
PLAN REPLAYER DUMP EXPLAIN (STMT_LIST);
PLAN REPLAYER DUMP EXPLAIN (
"SELECT * FROM t1 WHERE id = 1",
"SELECT * FROM t1 WHERE id > 1",
"SELECT * FROM t2 WHERE status = 'active'",
"SELECT * FROM t1, t2 WHERE t1.id = t2.id"
);
By combining them in a single Plan Replayer command, we can reduce the amount of duplicated data. For example, we only need to collect the stats data of t1 once instead of 3 times if we run single-SQL Plan Replayer command for them one by one.
A common usage of this could be: before upgrading, we use this command to dump all highly-frequent SQLs in this workload, and verify whether they'll have any plan regression in the new TiDB version.
How to organize the output file? If there are multiple statements:
- put these SQLs under
/sql, each SQL has a separate file, for example, /sql/sql0.sql, /sql/sql1.sql;
- create a new dictionary
explain and put their plans under it, each has a separate file, for example, /explain/explain0.txt, /explain/explain1.txt.
Enhancement
The current Plan Replayer implementation only supports dumping one SQL record at a time, and we could extend it to support multiple SQL records, for example:
By combining them in a single Plan Replayer command, we can reduce the amount of duplicated data. For example, we only need to collect the stats data of
t1once instead of 3 times if we run single-SQL Plan Replayer command for them one by one.A common usage of this could be: before upgrading, we use this command to dump all highly-frequent SQLs in this workload, and verify whether they'll have any plan regression in the new TiDB version.
How to organize the output file? If there are multiple statements:
/sql, each SQL has a separate file, for example,/sql/sql0.sql,/sql/sql1.sql;explainand put their plans under it, each has a separate file, for example,/explain/explain0.txt,/explain/explain1.txt.