EXPLAIN Command Product Documentation
Overview
EXPLAIN is a diagnostic command in Singdata Lakehouse used to analyze the execution plan of SQL queries. By examining the execution plan, users can understand query execution flow, identify performance bottlenecks, and perform targeted query optimization. This command supports both basic and extended output modes.
Command Syntax
Execution Plan Modes
1. Basic Execution Plan Mode (EXPLAIN)
The basic mode displays the physical execution plan of the query, used for quickly understanding how the query is executed.
Characteristics
- Lightweight Output: Shows the core steps of physical execution
- Quick Diagnosis: Used for quickly identifying the query execution approach
- Contents: Physical table scans, table data output, operator names, and stage information
Syntax
Example
Verification Result (Actual Output):
2. Extended Execution Plan Mode (EXPLAIN EXTENDED)
The extended mode displays the complete logical execution plan and physical execution plan, including more detailed optimization information.
Characteristics
-
Complete Output: Contains both logical plan and physical plan layers
-
Detailed Analysis: Shows expression transformations, system columns, optimization processes, etc.
-
Contents:
- Logical Execution Plan (LogicalPlan)
- Physical Execution Plan (DML)
- System Hidden Column Information
- Expression Type Conversion
Syntax
Example
The following command has been verified through Singdata MCP Server:
Verification Result (Actual Output):
Common Operators in Execution Plans
| Operator | Description | Performance Characteristics |
|---|---|---|
| PhysicalTableScan | Read data from table | Basic I/O operation |
| PhysicalTableSink | Output query results | Fixed overhead |
| PhysicalSort | Sort data | O(n log n), may become a bottleneck |
| PhysicalFilter | Conditional filter | Linear operation; early filtering is best practice |
| PhysicalHashAggregate | Aggregate operation | Varies based on GROUP BY cardinality |
| PhysicalJoin | JOIN operation | Complexity depends on JOIN strategy and data volume |
