OptionAGGREGATOR_OUTPUT_ROW_LIMIT
Description Number of rows allowed in queries with aggregate functions.
Introduced Version1.158
Default100 million rows

This parameter sets a limit to the number of rows allowed in queries with aggregate functions. If the limit set by this variable is exceeded, aggregate functions in the query get cancelled.

Large aggregate results consume significant heap memory. Memory usage peaks during query execution and is released when results are streamed to the client or the query completes.

This setting works in conjunction with:

  • CANCEL_QUERIES_EXCEEDING_AGGREGATE_OUTPUT_ROW_LIMIT - controls cancellation behavior

  • AD_HOC_TABLES_LIMIT - limits the number of ad-hoc tables allowed

  • EXACT_MATCH_LIMIT - controls exact match operations that may create large intermediate results

  • JVM heap size settings - determines available memory for large result sets

Consider memory limits holistically across all query result size controls.

When the limit is exceeded and cancellation is enabled, queries fail with error message: "Query cancelled: aggregate output exceeded limit of X rows". The query terminates immediately, releasing allocated resources. When cancellation is disabled, queries continue but may consume excessive memory and cause system instability with very large result sets.

Consider increasing the value if legitimate queries frequently hit the limit. Decrease if experiencing OutOfMemoryError during large aggregations.

Monitor for aggregate limit warnings in system logs with pattern "aggregate output exceeded limit". Track query performance metrics for long-running aggregations that approach the limit. High memory usage during aggregate queries may indicate queries producing results near the limit. Use query profiling to identify resource-intensive aggregations that may need optimization or limit adjustments.