From: | Tobias Brox <tobias(at)nordicbet(dot)com> |
---|---|
To: | "Jeffrey W(dot) Baker" <jwbaker(at)acm(dot)org> |
Cc: | Tobias Brox <tobias(at)nordicbet(dot)com>, pgsql-performance(at)postgresql(dot)org |
Subject: | Re: Limit + group + join |
Date: | 2005-08-26 02:06:35 |
Message-ID: | 20050826020635.GM10328@tobias.lan |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-performance |
[Jeffrey W. Baker - Thu at 06:56:59PM -0700]
> > explain select c.id from c join b on c_id=c.id group by c.id order by c.id
> > desc limit 5;
>
> Where's b in this join clause?
"join b on c_id=c.id"
It just a funny way of writing:
select c.id from c,b where c_id=c.id group by c.id order by c.id desc limit 5;
> It looks like a cartesian product to me.
No. The query will return exactly the same as the simplest query:
select c.id from c order by c.id desc limit 5;
As said, this is a gross oversimplification of the production envorinment.
In the production environment, I really need to use both join, group and
limit. I tested a bit with subqueries, it was not a good solution
(selecting really a lot of rows and aggregates from many of the tables).
The next idea is to hack it up by manually finding out where the "limit"
will cut, and place a restriction in the where-part of the query.
--
Notice of Confidentiality: This information may be confidential, and
blah-blah-blah - so please keep your eyes closed. Please delete and destroy
this email. Failure to comply will cause my lawyer to yawn.
From | Date | Subject | |
---|---|---|---|
Next Message | Jeffrey W. Baker | 2005-08-26 02:31:20 | Re: Limit + group + join |
Previous Message | Jeffrey W. Baker | 2005-08-26 01:56:59 | Re: Limit + group + join |