Uz.ytkownik Stephan Szabo napisa?:
Does using X.group_id=3 in the where clause work better?
It works better, but not if you want to create a view and make
"select * from some_view where group_id=3" :-(
On 7.3 with no statistics for the table, that appears
to move the filter into the subquery plan rather than the
outer users scan.
Do you mean the second query will work on 7.3?
select
group_id,
user_id,
a/sum_a as percent_a,
b/sum_b as percent_b
from
users U,
(select
sum(a) as sum_a,
sum(b) as sum_b
from users where group_id=U.group_id) X
where group_id=3;
Tomasz Myrta
---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]