HANA DBadvanced

HANA Performance Optimization & PlanViz

Diagnosing and resolving slow HANA queries using EXPLAIN PLAN, PlanViz, and column-store-aware optimization techniques.

Performance tuning specifically on HANA is a distinct skill from general SQL tuning, and interviewers who probe this topic want to see whether a candidate understands HANA's particular execution model well enough to reason about a slow query's actual bottleneck rather than applying generic relational database tuning habits that don't map cleanly onto a column-store, in-memory engine.

Reading a plain textual EXPLAIN PLAN is like reading a play's script and imagining the performance; PlanViz is watching the actual recorded performance with a stopwatch on each scene, immediately showing you which scene (query operation) ran unexpectedly long, rather than requiring you to imagine it from the script alone.

Key Concepts

1
The starting point for any HANA performance investigation is EXPLAIN PLAN, which shows the optimizer's chosen execution plan (join order, join algorithm, which operations pushed down to the column engine versus fell back to a row-oriented, less parallelizable execution path), and PlanViz (the visual plan analysis tool, available in HANA Studio/Eclipse or the web-based cockpit), which renders that plan graphically with per-operation timing and row-count data, making it far easier to spot the specific operation actually consuming the bulk of execution time rather than reading a dense textual plan.
EXPLAIN PLAN
2
A recurring HANA-specific bottleneck is unnecessary materialization - certain query patterns or procedural constructs (poorly structured SQLScript, certain join types, or filters applied too late in a query/view's logic) force the engine to materialize an intermediate result set into memory rather than keeping computation lazily pushed down and pipelined through the column engine, which both wastes memory and defeats parallelization; PlanViz specifically surfaces where materialization is happening so a developer can restructure the query/view to avoid it, often by pushing filters earlier or restructuring joins. Similarly, star join optimization (HANA's specific ability to recognize and specially optimize a fact-table-plus-multiple-dimension-tables join pattern, common in calculation views modeled as a Cube) only kicks in when the join structure is recognizable as a proper star schema, so poorly modeled joins can silently miss out on this optimization path entirely.
3
A senior-level answer also covers monitoring views like M_EXPENSIVE_STATEMENTS (capturing historically slow-running statements above a configured threshold for later analysis without needing to catch a query live) and M_SQL_PLAN_CACHE (showing cached execution plans and their statistics), and stresses the same measurement-first discipline seen in ABAP performance tuning - identify the actual bottleneck via PlanViz/expensive statements trace before attempting a fix, then re-measure to confirm the fix actually worked, rather than guessing based on general SQL tuning folklore that may not apply to HANA's specific engine internals.
M_EXPENSIVE_STATEMENTSM_SQL_PLAN_CACHE