Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> The count(distinct) you've got in there turns it off.
AAAH. That makes sense. Unfortunately I think I'm stuck with that, I'll have
to check though.
It was always a bit mysterious to me how postgres could implement
count(distinct) without introducing a separate sort and aggregate for each
occurrence.
I suppose it could rewrite it into an inner grouping with the added column,
then an outer grouping without it with a normal count(). But then that would
only work with a single count(distinct). And I'm not clear it would win for
this example either since there could actually be a pretty large number of
distinct values on that column. hmm...
Thanks for all the help.
--
greg