Re: BUG #10816: explain analyze reports different rows counts before and after sort - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #10816: explain analyze reports different rows counts before and after sort
Date
Msg-id 4200.1404137817@sss.pgh.pa.us
Whole thread Raw
In response to BUG #10816: explain analyze reports different rows counts before and after sort  (bashtanov@imap.cc)
List pgsql-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

pgsql-bugs by date:

Previous
From: Asif Naeem
Date:
Subject: Re: [HACKERS] BUG #9652: inet types don't support min/max
Next
From: rameshparnanditech@gmail.com
Date:
Subject: BUG #10817: archive settings