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

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to