Nested Loop Left Join always shows rows=1

From: Scara Maccai <m_lists(at)yahoo(dot)it>
To: postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Nested Loop Left Join always shows rows=1
Date: 2008-11-27 16:45:51
Message-ID: 492ECEBF.3040903@yahoo.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Query is:

"explain analyze select sum(A), count(*) from tab1 left outer join
tab_outer on id=out_id where id=10;"

output:

Aggregate (cost=31.91..31.92 rows=1 width=4) (actual
time=14.185..14.185 rows=1 loops=1)
-> Nested Loop Left Join (cost=0.00..17.11 rows=2959 width=4)
(actual time=8.608..13.400 rows=2953 loops=1)
-> Index Scan using id_idx on tab1 (cost=0.00..8.27 rows=1
width=4) (actual time=0.010..0.011 rows=1 loops=1)
Index Cond: (id = 10)
-> Index Scan using out_id_idx on tab_outer (cost=0.00..8.83
rows=1 width=8) (actual time=8.590..11.924 rows=2953 loops=1)
Index Cond: ((tab_outer.out_id = 10) AND (tab1.id =
tab_outer.out_id))

http://explain-analyze.info/query_plans/2519-query-plan-1240

I ran ANALYZE on both tables, but the plan shows rows=1 in the inner
table results.

If I change the "left outer join" into an "inner join" the bitmap index
scan of the inner table of the nested loop shows a correct number of
rows (not the exact same thing as "actual rows", but very close).

Am I reading the explain output in the wrong way?
I'm not complaining about performance issues, I'm just trying to learn
how to read plans.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ioana Danes 2008-11-27 17:20:24 Using postgres.log file for replication
Previous Message Csaba Együd 2008-11-27 14:06:00 Re: Separate Sessions?? (View data <-> Query tool)

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2008-11-27 17:14:37 Re: Review: Hot standby
Previous Message Robert Haas 2008-11-27 16:38:39 Re: Fwd: [PATCHES] Auto Partitioning Patch - WIP version 1