how can a multiple group by query be efficiently arranged?
the query
select A1,Z,count(*) from D group by A1,Z union
select A2,Z,count(*) from D group by A2,Z union
...
select An,Z,count(*) from D group by An,Z;
at least in Oracle is not optimized. One pass over D should be sufficient to compute the counts.
the query
select A1,Z,count(*) from D group by A1,Z union
select A2,Z,count(*) from D group by A2,Z union
...
select An,Z,count(*) from D group by An,Z;
at least in Oracle is not optimized. One pass over D should be sufficient to compute the counts.