Subject 'group by' and 'union' v.s. 'union all' have impact on the number of indxd reads
Author vincent_kwinsey
Hello!

I am trying to find optimal select statement. Currently I have only
indexed reads (no non-indexed reads), but I am still trying to minimize
this number - on some test cases I can see improvement some 10 times -
for the number of reads and execution time as well.

There are strange things:
- adding 'group by 1, 2, 3' clause removes all the optimization and
there is max number of reads
- 'union' remove all the optimization as opposite to 'union all'. In
case of 'union' the total number of reads excees the sum of reads for
individual selects (which are parts or 'union').

Intuition says than in both situations there should be some fixed
amount of reads and the 'group' or 'union' should simply make some
sorting or elimination of duplications of some temporary set and there
should be no additional reads...