From: Tom Lane <tgl@sss.pgh.pa.us>
To: bashtanov@imap.cc
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #10816: explain analyze reports different rows counts before and after sort
Date: Mon, 30 Jun 2014 10:16:57 -0400
Message-ID: <4200.1404137817@sss.pgh.pa.us> (raw)
In-Reply-To: <20140630094343.15698.80138@wrigleys.postgresql.org>
References: <20140630094343.15698.80138@wrigleys.postgresql.org>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
bashtanov@imap.cc writes:
> Please have a look at the two bottom nodes of the plan. Function scan
> produces 1000 rows, then they are sorted and turn into 3201 rows! How could
> this happen?
The discrepancy is easily explained because the sort is the righthand
child of a merge join. Merge join will rewind and rescan its right
child every time the left child produces duplicate keys, so that the
appropriate right-child rows get joined to all the similarly-keyed
rows from the left child. And you do have duplicate outputs coming
from that left child ...
IOW, it's just a measurement artifact arising from re-fetching the
same rows repeatedly. I think there's a warning about this in the
docs.
regards, tom lane
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: tgl@sss.pgh.pa.us, bashtanov@imap.cc
Subject: Re: BUG #10816: explain analyze reports different rows counts before and after sort
In-Reply-To: <4200.1404137817@sss.pgh.pa.us>
References: <20140630094343.15698.80138@wrigleys.postgresql.org> <4200.1404137817@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox