Interpreting Data in HANA SQL Analyzer: Identifying Bottlenecks and Parallelism in Query Execution
The HANA SQL Analyzer provides a visual and detailed view of query execution plans, allowing developers to pinpoint performance bottlenecks, assess resource utilization, and evaluate the effectiveness of parallel processing. This guide details the steps to generate and interpret these execution files.
On this page
The short answer
The HANA SQL Analyzer is a critical tool for performance tuning in SAP HANA, offering deep insights into how a SQL query is processed by the database engine. By analyzing the execution plan file, developers can determine the total execution time, the duration of individual operators, the number of records processed at each stage, and the degree of parallelization achieved. Identifying steps with disproportionately high costs or time consumption allows for targeted optimization of the underlying calculation views or SQL statements. The process involves generating a runtime plan file, loading it into the SQL Analyzer view, and systematically reviewing the timeline, operator metrics, and data flow.
Preparing the Analysis Environment
To effectively use the HANA SQL Analyzer, specific tools and system privileges must be in place. The primary environment for this analysis is SAP Business Application Studio (BAS), which requires the SAP HANA Performance Tools extension to be installed and active within the development space.
Access to the necessary system privileges, specifically TRACE ADMIN and INIFILE ADMIN, is mandatory for a user to analyze an SQL plan file. These privileges grant the required permissions to read and interpret the detailed execution statistics generated by the database engine.
Practical tip
If the SQL Analyzer shows a high cost associated with a specific join operator, review the join conditions and the modeling of the calculation view, specifically checking for filter pushdown and pruning effectiveness. If the total execution time is high but the individual operator times are low, investigate other phases visible in the timeline, such as query compilation or data transfer, as the SQL Analyzer snapshot alone may not identify the root cause.
Generating the SQL Plan File
The SQL Analyzer requires a runtime information file, known as the SQL plan file, which captures the execution details of a specific query. This file is generated without executing the query in a manner that would alter the execution environment, ensuring the captured data is accurate for analysis.
For a calculation view, the easiest method is to use the SAP HANA Database Explorer view within BAS. By selecting the HDI container and right-clicking the column view, the option to 'Generate SQL Statement' provides a direct link to the SQL Analyzer view, which automatically opens the plan file.
Loading and Viewing the Plan
If the plan file is generated outside of the integrated BAS tools, such as from an external SAP HANA Database Explorer, it must be manually managed. The generated plan file, typically with a .plv extension, needs to be downloaded to a local machine and then uploaded into a project folder within BAS using the context menu.
Once uploaded, the SQL Analyzer view is switched to, and the specific plan file is selected to display the results in the main window. This view presents the execution graph, which visually represents the sequence of operations performed by the database.
Interpreting Execution Timeline
The execution timeline provides a chronological sequence of all steps taken during the query execution. By reviewing this timeline, one can observe the total elapsed time and identify specific points in the execution where delays occurred.
This sequential view is crucial for understanding the flow of data processing, allowing the analyst to see exactly when compilation finished and when the actual data retrieval and processing began.
Analyzing Operator Costs
The core of performance analysis lies in examining individual operator metrics. Each step in the execution plan is represented by an operator, and the SQL Analyzer provides metrics for these operators, including the time consumed and the resources utilized.
Operators that consume a significantly higher percentage of the total execution time are flagged as potential bottlenecks. For instance, a complex join or a full table scan operator with a high cost indicates a need for optimization, such as improving join conditions or adding appropriate indexes.
Worked Example: Consider a query execution with a total time of 600ms. If Operator A (Filter) takes 100ms processing 1,000,000 records down to 10,000, Operator B (Join) takes 450ms processing those 10,000 records down to 500, and Operator C (Projection) takes 50ms processing 500 records, Operator B is the bottleneck. The analyst should conclude that the join operation is inefficient and requires optimization.
This analysis allows for targeted optimization of the underlying calculation views or SQL statements.
Counting Processed Records
The SQL Analyzer tracks the number of records processed at each stage of the query execution. This is a vital metric for verifying the efficiency of data filtering and pruning mechanisms.
If an early operator processes a massive number of records, but a subsequent filter operator reduces this count drastically, it suggests that the filtering could have been applied earlier in the execution plan to minimize data movement and processing overhead.
Evaluating Parallelization
The tool allows for checking the extent to which SAP HANA Cloud utilized parallel resources during the query execution. This evaluation helps determine if the query was effectively distributed across available processing units.
A well-optimized query should show evidence of parallel execution across multiple operators or stages, indicating that the database engine successfully leveraged its distributed architecture to speed up processing.
Identifying Bottlenecks
Bottleneck identification is the synthesis of all gathered data. By cross-referencing the timeline, operator costs, and record counts, the analyst can pinpoint the exact step causing performance degradation.
For example, if an operator has a high execution time and processes a large number of records, it is a primary candidate for optimization. Conversely, if an operator has low time but high record counts, it suggests inefficient data handling upstream.
Things to check
- Verify that the SAP HANA Performance Tools extension is installed in the BAS development space.
- Confirm that the user possesses the TRACE ADMIN and INIFILE ADMIN system privileges.
- Ensure the SQL plan file is correctly generated from the desired query execution context.
- Check the execution timeline to confirm the total elapsed time matches performance expectations.
- Compare the record counts between sequential operators to detect unexpected data expansion or premature filtering.
Where this applies
The SQL Analyzer provides a snapshot of a single execution. It cannot predict performance under varying data distributions or parameter changes. Furthermore, the analysis is dependent on the quality of the generated plan file, which is influenced by the specific configuration and version of the SAP HANA database instance.