Performance Tuning: Expensive Statements, Plan Visualizer & Memory Triage
Master performance triage in SAP HANA: configuring Expensive Statement Tracing, deciphering Plan Visualizer (PlanViz) execution operators, resolving Out-of-Memory (OOM) dumps, and terminating runaway sessions safely.
Core Learning Objectives
- 1.Enable and configure Expensive Statement Tracing dynamically in global.ini.
- 2.Analyze the critical diagnostic columns in SYS.M_EXPENSIVE_STATEMENTS.
- 3.Interpret Plan Visualizer (PlanViz) operators, dominant execution paths, and engine switching overhead.
- 4.Investigate Out-of-Memory (OOM) trace files, Global Allocation Limits, and heap allocators.
- 5.Execute emergency session cancellation and disconnection.
Definition & Architectural Rationale
Technical Definition:
An Expensive SQL Statement is any query whose execution duration, CPU cycles, memory allocation, or lock wait time exceeds configured performance thresholds, risking server starvation, user freezes, or Out-of-Memory crashes.
Why this component exists:
In large ERP environments with thousands of concurrent users and custom ABAP reports, poorly indexed queries or missing join conditions can easily request billions of rows or allocate tens of gigabytes of RAM. Identifying and tuning these queries proactively is the primary responsibility of a senior DBA.
Internal Working & Mechanics
Architecture Flow Diagram
Production SQL Diagnostics
Dynamically enables expensive statement tracing with a 2-second threshold and 1GB memory threshold.
Isolates statements with the largest peak memory footprints risking Out-of-Memory conditions.
Key Diagnostic Columns
MEM_ALLOC_GB:Peak memory allocated by this querySTATEMENT_HASH:Unique identifier for query planSHORT_SQL:Preview of query textExpected Diagnostic Output
STATEMENT_HASH | USER_NAME | APPLICATION_NAME | MEM_ALLOC_GB | RUNTIME_SEC | RECORDS | SHORT_SQL ----------------------------------------------------------------------------------------------------------------------------- f8102914bb10294109204910a8f9210c | BATCH_REP | ABAP:Z_FIN_REP | 34.50 | 180.20 | 25000000 | SELECT * FROM BSEG INNER JOIN BKPF...
Troubleshooting & Root Cause Analysis
Production Best Practices & Operational Risks
Mandatory Best Practices
- Configure [memorymanager] statement_memory_limit = 40 (or 25% of GAL) in tenant indexserver.ini to automatically abort individual rogue queries.
- Do not keep expensive_statement tracing enabled with threshold_duration = 0; capturing every query introduces significant logging overhead.