Skip site navigation (1) Skip section navigation (2)

Re: sub-select with aggregate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: Tomasz Myrta <jasiek(at)klaster(dot)net>, pgsql-sql(at)postgresql(dot)org
Subject: Re: sub-select with aggregate
Date: 2002-10-24 20:32:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com> writes:
> Basically, as I understand it,
>  select * from a,b where a.a=b.a and a.a=3;
> isn't going to realize that b.a=3 and act as if
> you typed that.

We have talked about adding code to make that deduction.  The issue is
how to do so without expending a lot of cycles (that will be wasted in
every query where no improvement results, which is most of them).  There
are also some ticklish issues about side-effects of adding such clauses.
in the above example, if we did filter b with b.a=3, then the join
clause a.a=b.a becomes a no-op and does not reduce the number of rows;
if we fail to account for that fact we will underestimate the number of
rows out of the join, possibly pessimizing higher levels of plan.  Also,
we might as well implement the join as a nestloop; no percentage in
fooling with hash or merge overhead.

I have some thoughts about this, but it's not happening for 7.3 ...

			regards, tom lane

In response to

pgsql-sql by date

Next:From: Charles H. WoloszynskiDate: 2002-10-25 01:13:24
Subject: High Availability PostgreSQL solution?
Previous:From: Stephan SzaboDate: 2002-10-24 16:39:14
Subject: Re: sub-select with aggregate

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group