Hi,

I’m using postgres 7.4.

 

I have two queries:

(1)

SELECT  a,b

FROM table1

WHERE a=99

 

(2)

SELECT  a,b,sum (o)  as sum_o

FROM table2

GROUP BY a,b

 

Both Runs very fast.

 

But when I try to make (2) as a subquery of (1):

 

SELECT  a,b,sum_o

FROM table1

LEFT JOIN  (

SELECT  a,b,sum (o)  as sum_o

                        FROM table2

GROUP BY a,b

) sub_query

USING (a,b)

WHERE a=99

 

 

It runs 100 times slower.

I guess it has to do with the postgres unable to pass the a=99 inside the subquery

 

Any ideas ?

 

ishay

Reply via email to