Skip to Content
0
Former Member
May 29, 2013 at 09:08 AM

independent sum of two columns causes the performance down apparently.

183 Views

I have met this issue.

I have a table t with 3 columns, id1,id2, num.

I am doing this

select a.id2 m, b.id2 n, sum(a.num), sum(b.num)

from t a, t b

where a.id1=b.id1

group by a.id2, b.id2;

the problem is if I don't do the two sums. the speed is quite well.

if I add one of the sums, the speed is still reasonable, but if I add the two sums together, the speed goes down two much, about double time needed.

Anyone can help on this? I think the table is a column one, the calculation of the two sums should be done in parallel, so there should not be so much different in speed.

by the way, I used the 'request_flags'='ANALYZE_MODEL' in the testing. so the real sql is

select a.id2 m, b.id2 n, sum(a.num), sum(b.num)

from t a, t b

where a.id1=b.id1

group by a.id2, b.id2

'request_flags'='ANALYZE_MODEL'

;