Re: Nested Loop Left Join always shows rows=1

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Scara Maccai <m_lists(at)yahoo(dot)it>
Cc: postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: Nested Loop Left Join always shows rows=1
Date: 2008-12-01 21:09:40
Message-ID: 1135.1228165780@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

Scara Maccai <m_lists(at)yahoo(dot)it> writes:
> 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).

Yeah, this is a bug: it's effectively double-counting the selectivity of
the index clause. The error isn't enormously critical, since the join
size estimate is right; but it could perhaps lead to choosing a plain
indexscan when a bitmap scan would be better. I've applied a patch.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2008-12-01 21:28:54 Re: Indexes on NULL's and order by ... limit N queries
Previous Message Maxim Boguk 2008-12-01 21:00:52 Re: Indexes on NULL's and order by ... limit N queries

Browse pgsql-hackers by date

  From Date Subject
Next Message Raymond O'Donnell 2008-12-01 22:33:14 Re: [pgsql-www] Reg: Nested query
Previous Message Emmanuel Cecchet 2008-12-01 20:50:42 Re: Transactions and temp tables