TATECHATLAS
◎ English
SAP & ERP / Tip

Analyzing SQL Execution Plans with HANA SQL Analyzer in SAP HANA Cloud

Debug Query mode shows pushdown and pruning, while HANA SQL Analyzer reports actual execution: timings, row counts, parallelism and engines. Analyzing a plan file in HANA SQL Analyzer requires the SAP HANA Performance Tools extension in the development space and both TRACE ADMIN and INIFILE ADMIN for the analyzing user.

On this page

Put the SQL in an SQL Console (no execution needed), choose Analyze -> Generate SQL Analyzer Plan File, set a prefix and Save; the file opens in HANA SQL Analyzer when it was produced from the embedded SAP HANA Database Explorer, otherwise download the .plv and upload it to a project folder. The analyzing user must be the HDI technical user <container_schema_name>...RT or a classic database user holding both SYSTEM privileges TRACE ADMIN and INIFILE ADMIN, and the development space must carry the SAP HANA Performance Tools extension, which can be added only while the space is stopped. Use Debug Query mode when you only need to inspect filter pushdown and data pruning.

Context and recommendation

Debug Query mode answers a structural question: it shows how filters are pushed down and how data is pruned, but it does not tell you how the SQL actually performs. The runtime questions are different: total execution time, how long each step took, whether some steps are much slower than others, where bottlenecks are, how many records each step processed, in what sequence steps run, which operators are called, to what extent HANA Cloud parallelized the query, which processing engines were invoked, and whether all query plan steps were unfolded.

For those questions use the HANA SQL Analyzer view in SAP Business Application Studio. The prerequisite is the SAP HANA Performance Tools extension in the development space, and it can be added only while the space is stopped. Then obtain the SQL, for example by right-clicking a column view in the embedded SAP HANA Database Explorer and choosing Generate SQL Statement, place it in an SQL Console (you do not need to execute it), and choose Analyze -> Generate SQL Analyzer Plan File, enter a file-name prefix and Save. The location is already set and cannot be changed at that stage; from the embedded Database Explorer the plan file opens immediately in HANA SQL Analyzer.

Reasoning and trade-offs

The route you take to the plan file decides how much manual work follows. A plan generated from the embedded SAP HANA Database Explorer opens directly in the analyzer. A plan produced from Data Preview or from the external SAP HANA Database Explorer must be downloaded as a .plv file, uploaded into a project folder through the context menu Upload, and then selected in HANA SQL Analyzer.

Analysis runs either as the technical user <container_schema_name>...RT of the HDI container or as a classic database user, and in both cases the user analyzing the query needs two SYSTEM privileges: TRACE ADMIN and INIFILE ADMIN. The source documents the SAP HANA Performance Tools extension and the two privileges only for the HANA SQL Analyzer view and for analyzing a plan file; Debug Query mode is presented as a structural check without those stated requirements. SQL Analyzer is not restricted to calculation views: it works wherever SQL is defined, for example table functions, and the statement can be modified before analysis, such as removing columns to check that node or data source pruning behaves as expected.

The trade-off is therefore scope versus setup: Debug Query mode is a fast structural check, while SQL Analyzer captures run-time information for one particular execution and demands extension installation and elevated privileges.

Concrete illustration

Decision table for choosing the path. Row 1: goal is pushdown or pruning inspection only -> Debug Query mode -> no extension, no TRACE ADMIN or INIFILE ADMIN -> answer is structural, no timing. Row 2: goal is execution analysis and the SQL Console was opened from the embedded Database Explorer -> Generate SQL Analyzer Plan File -> file opens directly in HANA SQL Analyzer -> drill-down on the execution graph, timeline of compilation and execution, and the list of tables used. Row 3: goal is execution analysis from Data Preview or the external Database Explorer -> generate, Download the .plv, Upload to a project folder, select the file in SQL Analyzer -> same analysis after two transfer steps. Row 4: plan files needed later -> embedded Database Explorer files live in /home/user/.vscode/data/User/globalStorage/sapse.hana-database-explorer/ and can be opened or moved to the project; external Database Explorer files are under Catalog -> Database Diagnostic Files -> <DB Instance ID> -> other inside the HDI container and must be downloaded and uploaded again.

The SQL below is the kind of statement placed in the SQL Console; the grants are separate administrative actions performed by a user who may delegate those privileges. The SELECT returns result rows and is what the plan file describes, while each GRANT produces no result set and only changes authorization state.

SELECT "MEASURE", "CATEGORY" FROM "demo.pkg::SalesView" WHERE "CATEGORY" = 'A'; GRANT TRACE ADMIN TO ANALYZE_USER; GRANT INIFILE ADMIN TO ANALYZE_USER;

SELECT "MEASURE", "CATEGORY" FROM "demo.pkg::SalesView" WHERE "CATEGORY" = 'A';
GRANT TRACE ADMIN TO ANALYZE_USER;
GRANT INIFILE ADMIN TO ANALYZE_USER;

Applicability limits

SQL Analyzer analyzes the plan of a specific execution; it does not replace Debug Query mode for verifying pushdown and pruning, and the two answer different questions. It applies to any SQL, including calculation views and table functions, but only when the SAP HANA Performance Tools extension is present, which cannot be added to a running development space, and only when the analyzing user holds TRACE ADMIN and INIFILE ADMIN.

The plan file location is fixed when the file is generated, and later access depends on how it was created: embedded Database Explorer files are reachable from the file system path above, whereas files from other tools must be downloaded and uploaded again. The available material describes the analysis process but gives no concrete execution-time thresholds and no method for choosing between plan variants and rewriting a query, so such optimization decisions need separate measurement on your own workload.

Applicability

  • Do you need per-step timing, row counts, parallelism or engine information, or only pushdown and pruning?
  • Is the development space stopped so SAP HANA Performance Tools can be added?
  • Does the analyzing user hold both TRACE ADMIN and INIFILE ADMIN?
  • Will you analyze as <container_schema_name>...RT or as a classic database user?
  • Was the SQL Console opened from the embedded Database Explorer, avoiding a .plv download and upload?
  • Is the target statement a calculation view, or other SQL such as a table function?
  • Can you locate an existing plan file in globalStorage or in Database Diagnostic Files?
  • Do you have a concrete execution to capture, since the plan file reflects one run?

The source describes the workflow, prerequisites and privileges for HANA SQL Analyzer but supplies no execution-time thresholds, no latency or throughput figures, and no procedure for choosing between plan variants and query rewriting. It also does not document the analyzer's individual metrics beyond the listed capabilities (timeline, drill-down graph, tables used), so exact field meanings, version-specific menu wording and privilege-administration procedures must be confirmed against the SAP HANA Cloud release and your tenant configuration. Plan files are tied to a particular execution and to the tool that produced them.

Sources

  1. SAP Learning: Analyzing executions with the SQL Analyzer ↗
  2. SAP Learning: Using plan variants to optimize parameterized queries ↗
Back to top ↑