Skip to content

Suggestion: Improve execution plan readability by using concise notation for execution_method #208

@apstndb

Description

@apstndb

Spanner execution plans are becoming increasingly complex over time. Even plans for simple queries, which used to format neatly, now require significantly more screen width than before. A major contributor to this is the execution_method metadata, which now commonly appears on almost every operator.

For example, consider the plan for EXPLAIN SELECT * FROM Singers;:

EXPLAIN
SELECT * FROM Singers;
+----+------------------------------------------------------------------------------------------------------+
| ID | Query_Execution_Plan                                                                                 |
+----+------------------------------------------------------------------------------------------------------+
|  0 | Distributed Union (distribution_table: Singers, execution_method: Row, split_ranges_aligned: false)  |
|  1 | +- Local Distributed Union (execution_method: Row)                                                   |
|  2 |    +- Serialize Result (execution_method: Row)                                                       |
|  3 |       +- Table Scan (Full scan: true, Table: Singers, execution_method: Row, scan_method: Automatic) |
+----+------------------------------------------------------------------------------------------------------+

This causes a couple of issues:

  • It significantly impacts screen width, as execution_method is almost always included, often making lines much longer.
  • It makes the execution plan overly verbose.

There is precedent within spanner-cli for displaying necessary information concisely instead of showing raw metadata, balancing readability and horizontal space savings. Previous efforts include:

Following this approach, I propose introducing a dedicated, more concise notation specifically for the execution_method metadata to save screen width and improve readability.

Note: While simply hiding execution_method entirely might seem like an option, it's an important concept documented for query optimization (SQL best practices: Optimize query execution). A tool useful for query optimization probably shouldn't hide such a key piece of information.

For reference, in a fork I'm currently developing (spanner-mycli), I am experimenting with a notation that displays it like <Row> or <Batch> appended to the operator's display name.

See example implementation and the resulting output format:
apstndb/spanner-mycli#178

+----+-------------------------------------------------------------------------------------+
| ID | Query_Execution_Plan                                                                |
+----+-------------------------------------------------------------------------------------+
|  0 | Distributed Union <Row> (distribution_table: Singers, split_ranges_aligned: false)  |
|  1 | +- Local Distributed Union <Row>                                                    |
|  2 |    +- Serialize Result <Row>                                                        |
|  3 |       +- Table Scan <Row> (Full scan: true, Table: Singers, scan_method: Automatic) |
+----+-------------------------------------------------------------------------------------+

Adopting a similar concise format in spanner-cli could significantly improve the usability of execution plan analysis, especially on screens with limited width.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions