Managing Parallelism and Table Partitioning for Large Queries in SAP HANA Cloud
Use SQL Analyzer to see how far HANA parallelized a query, then partition large tables on a key aligned with common filters. Partitioning creates segments the engine can process concurrently, but a skewed key can undo the gain.
On this page
Key idea
Measure first, then restructure: generate a SQL Analyzer plan file to see total time, per-step time, records per step, and the degree of parallelization actually achieved. If the plan shows one long scan or uneven work across branches, partition the large table on a column that matches the dominant filter (typically a date range or a low-cardinality business key). Partitioning gives the optimizer segments it can prune and scan in parallel; it does not by itself make every query faster, so the partition key must align with real predicates and the data must be reasonably evenly distributed.
Context and Recommendation
SAP HANA Cloud can spread an analytical query across multiple cores, but it can only do so when the plan contains separable units of work. The SQL Analyzer lesson states the diagnostic questions directly: what was the total execution time, how long did each step take, which steps are bottlenecks, how many records did each step process, and to what extent was SAP HANA Cloud able to parallelize the query. Those answers tell you whether the problem is a single expensive operator or a table that offers no natural split.
The practical recommendation is a two-stage workflow. First, put the SQL in an SQL Console and use Analyze, Generate SQL Analyzer Plan File to capture runtime facts, including which processing engines were invoked and whether all plan steps unfolded. Second, if the bottleneck is a large scan, change the physical structure by partitioning the table, because query-level tuning alone cannot create parallel work where the storage layout provides none.
Prerequisites are an SAP HANA Cloud instance, privileges to alter table structures, and the SAP HANA Performance Tools extension in your SAP Business Application Studio space (the space must be stopped to add it). Running the analyzer requires the SYSTEM privileges TRACE ADMIN and INIFILE ADMIN, either as the HDI container technical user or a classic database user.
Reasoning and Trade-offs
Partitioning divides one column-store table into physically separate ranges or values. When a query filters on the partition key, the optimizer can prune partitions it does not need, so each worker thread reads a smaller slice; the remaining slices can then be processed concurrently. The mechanism is therefore twofold: less I/O and computation per thread, plus more threads with useful work. The same plan file that showed weak parallelization should show more balanced branches after the change.
The trade-off is skew. If one partition holds a disproportionate share of rows, the longest partition still sets the query duration and the extra threads idle. Range keys built on an unevenly growing dimension, such as a status column with 95 percent of rows in one value, reproduce the original serial bottleneck inside a more complex object. Over-partitioning adds metadata and maintenance cost, and repartitioning a populated table is an expensive operation that needs a maintenance window.
Parameterized queries add a second source of variance. The plan variants material explains that caching a single execution plan is suboptimal when filter selectivity and data distributions vary, and that HANA can cache multiple plans per parameterized statement based on filter selectivity. Active variants and their execution statistics can be inspected in M_SQL_PLAN_VARIANTS and M_SQL_PLAN_VARIANT_STATISTICS, which helps distinguish a partitioning problem from a plan-selection problem.
Concrete Illustration
Consider a sales fact table with billions of rows where the reporting workload filters by invoice period. Partitioning it by INVOICEDATE lets a Q1 query read only the January through March partitions and process those segments in parallel, instead of scanning the whole year. The DDL below is an illustrative range-partition definition; partition names, boundary syntax, and the final catch-all partition must be checked against your exact HANA Cloud version before execution.
The following query then prunes to the partitions overlapping the requested window. In the resulting plan file, the scan step should show fewer records than a full-table scan and several parallel branches; those figures are illustrative expectations, not observed measurements, and must be confirmed by comparing two plan files from your own system.
Applicability Limits
Partition pruning pays off when the table is large and the query carries range or equality predicates on the partition key. Small tables gain little and may lose to metadata overhead; queries that must aggregate the entire table, join across every partition, or filter only on non-partition columns still read all segments, so the management complexity buys nothing.
Cross-partition joins deserve particular care: pruning one side does not prune the other, and a join key unrelated to the partition key can force full scans on both inputs. Likewise, a date-partitioned table helps only if the workload actually restricts dates; a dashboard that always reports year-to-date will touch every partition.
Finally, partitioning is not a substitute for plan stability. If executions fluctuate because parameter values and data skews select different plans, address that with plan management rather than expecting new partitions to fix it. Revalidate with SQL Analyzer after any structural change, and treat the result as workload-specific rather than a general guarantee.
Applicability
- Does the dominant query predicate use the proposed partition key with range or equality conditions?
- Does the SQL Analyzer plan show one long step, or an uneven distribution of records across parallel branches?
- Is the table large enough that partition metadata and repartitioning cost are justified?
- Is the candidate key balanced, or would one value or range hold most of the rows?
- Do most workloads query single periods, or do they require full scans and cross-partition joins?
- Do M_SQL_PLAN_VARIANTS and M_SQL_PLAN_VARIANT_STATISTICS show parameter-driven plan fluctuations instead of a layout problem?
- Do you hold privileges to alter table structures, and can you capture before-and-after plan files?
- Is the exact partition syntax verified against your SAP HANA Cloud version and configuration?
Where this applies
The source material supports using SQL Analyzer to expose bottlenecks and parallelization, and supports partitioning and plan variants as optimization levers, but it does not specify version-dependent partition DDL, degree-of-parallelism hints, or expected speedups. Partitioning only helps when filters align with the key; skewed or over-fine partitions add overhead, cross-partition joins may see no gain, and repartitioning populated tables is costly. All syntax and performance claims here must be validated on your own instance.