Skip to content

planner: Plan Replayer supports dumping multiple SQL records at once #66151

Description

@qw4990

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:

  1. put these SQLs under /sql, each SQL has a separate file, for example, /sql/sql0.sql, /sql/sql1.sql;
  2. create a new dictionary explain and put their plans under it, each has a separate file, for example, /explain/explain0.txt, /explain/explain1.txt.

Metadata

Metadata

Assignees

No one assigned

    Labels

    sig/plannerSIG: Plannertype/enhancementThe issue or PR belongs to an enhancement.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions