Re: join removal - Mailing list pgsql-hackers

From Pavel Stehule
Subject Re: join removal
Date
Msg-id 162867791003290119v7be285f1q6f49be88bb7213e9@mail.gmail.com
Whole thread Raw
In response to Re: join removal  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: join removal
List 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=5760000width=4)  ->  Seq Scan on a  (cost=0.00..34.00 rows=2400 width=4)  ->  Materialize  (cost=0.00..46.00
rows=2400width=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
Scanon b  (cost=0.00..34.00 rows=2400 width=0)
 
(5 rows)

Regards
Pavel Stehule


pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: More idle thoughts
Next
From: Joachim Wieland
Date:
Subject: Re: five-key syscaches