From: Ishay Pomerantz <ishay@ovdimnet.co.il>
To: pgsql-sql@postgresql.org
Subject: Problem with subquery containg GROUP BY
Date: Tue, 28 Dec 2004 09:31:15 -0800
Message-ID: <000401c4ed03$08a23730$92fadb3e@mazcal> (raw)
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 instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ishay@ovdimnet.co.il
Subject: Re: Problem with subquery containg GROUP BY
In-Reply-To: <000401c4ed03$08a23730$92fadb3e@mazcal>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox