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

Re: WIP Join Removal

From: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: List pgsql-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: WIP Join Removal
Date: 2008-09-02 11:20:41
Message-ID: 48BD2189.40400@enterprisedb.com (view raw or flat)
Thread:
Lists: pgsql-patches
Simon Riggs wrote:
> select a.col2
> from a left outer join b on a.col1 = b.col1
> where b.col2 = 1;
> 
> is logically equivalent to 
> 
> select a.col2
> from a;

No, it's not:

postgres=# CREATE TABLE a (col1 int4, col2 int4);
CREATE TABLE
postgres=# CREATE TABLE b (col1 int4, col2 int4);
CREATE TABLE
postgres=# INSERT INTO a VALUES (1,1);
INSERT 0 1
postgres=# select a.col2 from a;
  col2
------
     1
(1 row)

postgres=# select a.col2 from a left outer join b on a.col1 = b.col1 
where b.col2 = 1;
  col2
------
(0 rows)

But anyway, Greg's example looks valid, and proves the point that 
removing a join isn't always a win.

-- 
   Heikki Linnakangas
   EnterpriseDB   http://www.enterprisedb.com

In response to

Responses

pgsql-patches by date

Next:From: Simon RiggsDate: 2008-09-02 11:38:18
Subject: Re: WIP Join Removal
Previous:From: Simon RiggsDate: 2008-09-02 11:20:13
Subject: Re: WIP Join Removal

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