Optimize TEMP_DB_RAM usage by applying GROUP BY on UNION ALL branches

Details

Detail name Value
Changelog Number 27055
Type Improvement
Status Resolved
Fix Versions Exasol 2026.1.0
Resolution Date 2026-05-15

Background

Consider an aggregated query over a UNION ALL subselect, for example:

SELECT X, SUM(Y) FROM (SELECT * FROM A UNION ALL SELECT * FROM B WHERE X < 100 ) GROUP BY X

SELECT SUM(X) FROM (SELECT * FROM A UNION ALL SELECT * FROM B WHERE X < 100);

In such cases, the UNION ALL subselect was materialized in its entirety, and then the aggregation takes place. This may lead to very large TEMP_DB_RAM usage due to this materialization.

Improvement

The aggregation is performed on each UNION ALL branch and then the results are combined, with potentially large gains in TEMP_DB_RAM usage and query duration.