From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | hs(at)cybertec(dot)at |
Cc: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Using the same condition twice |
Date: | 2002-11-24 21:56:09 |
Message-ID: | 5000.1038174969@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
I wrote:
> Interesting. We seem to recognize the fact that the extra clause is
> redundant in nearly all places ... but not in indexscan plan generation.
> I tried this simplified test case:
> create table t_wert(werttypid int);
> create table t_werttyp(id int);
> create index idx_wert_werttypid on t_wert(werttypid);
> explain select * from
> t_wert JOIN t_werttyp ON (t_werttyp.id = t_wert.werttypid)
> where t_werttyp.id = t_wert.werttypid;
> explain select * from
> t_wert JOIN t_werttyp ON (t_werttyp.id = t_wert.werttypid);
FYI, I have committed changes that seem to fix this problem in CVS tip.
regression=# set enable_mergejoin to 0;
SET
regression=# set enable_hashjoin to 0;
SET
regression=# explain select * from
regression-# t_wert JOIN t_werttyp ON (t_werttyp.id = t_wert.werttypid)
regression-# where t_werttyp.id = t_wert.werttypid;
QUERY PLAN
----------------------------------------------------------------------------------------
Nested Loop (cost=0.00..17150.00 rows=5000 width=8)
-> Seq Scan on t_werttyp (cost=0.00..20.00 rows=1000 width=4)
-> Index Scan using idx_wert_werttypid on t_wert (cost=0.00..17.07 rows=5 width=4)
Index Cond: ("outer".id = t_wert.werttypid)
(4 rows)
regression=# explain select * from
regression-# t_wert JOIN t_werttyp ON (t_werttyp.id = t_wert.werttypid);
QUERY PLAN
----------------------------------------------------------------------------------------
Nested Loop (cost=0.00..17150.00 rows=5000 width=8)
-> Seq Scan on t_werttyp (cost=0.00..20.00 rows=1000 width=4)
-> Index Scan using idx_wert_werttypid on t_wert (cost=0.00..17.07 rows=5 width=4)
Index Cond: ("outer".id = t_wert.werttypid)
(4 rows)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Christopher Kings-Lynne | 2002-11-24 22:55:52 | Re: pg_atoi: zero length string |
Previous Message | Tom Lane | 2002-11-24 21:16:46 | Re: Help with ADD COLUMN |