Re: Spurious rows returned with left join?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Edmund Bacon <ebacon(at)onesystem(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Spurious rows returned with left join?
Date: 2006-04-04 21:30:58
Message-ID: 14663.1144186258@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Edmund Bacon <ebacon(at)onesystem(dot)com> writes:
> Consider the following:
> ...
> Note that I get 2 rows where t1_a = 3.

Are you getting a Merge Right Join plan for that? If so, you're likely
getting bit by this bug:

2006-03-17 14:38 tgl

* src/: backend/executor/nodeMergejoin.c,
test/regress/expected/join.out, test/regress/expected/join_1.out,
test/regress/sql/join.sql (REL8_1_STABLE),
backend/executor/nodeMergejoin.c, test/regress/expected/join.out,
test/regress/expected/join_1.out, test/regress/sql/join.sql: Fix
bug introduced into mergejoin logic by performance improvement
patch of 2005-05-13. When we find that a new inner tuple can't
possibly match any outer tuple (because it contains a NULL), we
can't immediately skip the tuple when we are in NEXTINNER state.
Doing so can lead to emitting multiple copies of the tuple in
FillInner mode, because we may rescan the tuple after returning to
a previous marked tuple. Instead, proceed to NEXTOUTER state the
same as we used to do. After we've found that there's no need to
return to the marked position, we can go to SKIPINNER_ADVANCE state
instead of SKIP_TEST when the inner tuple is unmatchable; this
preserves the performance improvement. Per bug report from Bruce.
I also made a couple of cosmetic code rearrangements and added a
regression test for the problem.

This'll be fixed in 8.1.4, or if you're in a hurry you can get the patch
from our CVS server.

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-04-04 21:53:01 Re: CREATE TABLE (with INHERITS) and ACCESS EXCLUSIVE locks
Previous Message Magnus Hagander 2006-04-04 21:14:42 Re: Why postgres install requires physical access to server in windows