Some restrictions apply to situations and queries that benefit from a split GROUP BY.
CREATE VIEW viewA (va1 int, va2 int, va3 int, va4 int) AS SELECT b1, b2, b3, b4 FROM tableB UNION SELECT c1, c2, c3, c4 FROM tableC; SELECT SUM(va1) FROM viewA GROUP BY va3;
CREATE VIEW viewA (va1 int, va2 int, va3 int, va4 int) AS SELECT b1, b2, b3, b4 FROM tableB UNION ALL SELECT c1, c2, c3, c4 FROM tableC; SELECT SUM(DISTINCT va1) FROM viewA GROUP BY va3;
CREATE VIEW viewA (va1 int, va2 int, va3 int, va4 int) AS SELECT b1, b2, b3, b4 FROM tableB UNION ALL SELECT c1, c2, c3, c4 FROM tableC UNION ALL SELECT d1, d2, d3, d4 FROM tableD UNION ALL SELECT e1, e2, e3, e4 FROM tableE UNION ALL SELECT f1, f2, f3, f4 FROM tableF UNION ALL SELECT g1, g2, g3, g4 FROM tableG; SELECT SUM(va1) FROM viewA GROUP BY va3;In this example, the Sybase IQ optimizer splits the GROUP BY and inserts six GROUP BY operators into the query plan. Consequently, the query requires more temporary cache to store aggregation information and data. If the system cannot allocate enough cache, the optimizer does not split the GROUP BY.You can use the TEMP_CACHE_MEMORY_MB database option to increase the size of the temporary cache, if memory is available.
In order for the query to benefit from split GROUP BY, the AGGREGATION_PREFERENCE database option should be set to its default value of 0. This value allows the Sybase IQ optimizer to determine the best algorithm to apply to the GROUP BY. The query does not benefit from split GROUP BY, if the value of AGGREGATION_PREFERENCE forces the Sybase IQ optimizer to choose a sort algorithm to process the GROUP BY. The option AGGREGATION_PREFERENCE can be used to override the optimizer's choice of algorithm for processing the GROUP BY and should not be set to 1 or 2 in this case.