Re: join removal

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Greg Stark <stark(at)mit(dot)edu>, "<pgsql-hackers(at)postgresql(dot)org>" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: join removal
Date: 2010-03-29 08:19:37
Message-ID: 162867791003290119v7be285f1q6f49be88bb7213e9@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

is any reason why join removal doesn't remove useless relation b?

postgres=# \d a
Table "public.a"
Column | Type | Modifiers
--------+---------+-----------
a | integer |
Indexes:
"a_a_idx" UNIQUE, btree (a)

postgres=# \d b
Table "public.b"
Column | Type | Modifiers
--------+---------+-----------
b | integer |
Indexes:
"b_b_idx" UNIQUE, btree (b)

postgres=# explain select a from a left join b on true;
QUERY PLAN
-------------------------------------------------------------------
Nested Loop Left Join (cost=0.00..72074.00 rows=5760000 width=4)
-> Seq Scan on a (cost=0.00..34.00 rows=2400 width=4)
-> Materialize (cost=0.00..46.00 rows=2400 width=0)
-> Seq Scan on b (cost=0.00..34.00 rows=2400 width=0)
(4 rows)

postgres=# explain select distinct a from a left join b on true;
QUERY PLAN
---------------------------------------------------------------------------------
Unique (cost=0.00..86520.25 rows=2400 width=4)
-> Nested Loop Left Join (cost=0.00..72120.25 rows=5760000 width=4)
-> Index Scan using a_a_idx on a (cost=0.00..80.25 rows=2400 width=4)
-> Materialize (cost=0.00..46.00 rows=2400 width=0)
-> Seq Scan on b (cost=0.00..34.00 rows=2400 width=0)
(5 rows)

Regards
Pavel Stehule

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joachim Wieland 2010-03-29 08:21:46 Re: five-key syscaches
Previous Message Simon Riggs 2010-03-29 08:15:10 Re: More idle thoughts