See these examples to see how a split GROUP BY improves performance.
CREATE VIEW unionTab (v1 int, v2 int, v3 int, v4 int) AS SELECT a, b, c, d FROM tabA1 UNION ALL SELECT a, b, c, d FROM tabA2 UNION ALL SELECT a, b, c, d FROM tabA3 UNION ALL SELECT a, b, c, d FROM tabA4;The Sybase IQ optimizer splits the GROUP BY operation in the following queries and improves query performance:
SELECT v1, v2, SUM(v3), COUNT(*) FROM unionTab GROUP BY v1, v2; SELECT v3, SUM(v1*v2) FROM unionTab GROUP BY v3;