Re: Sort operation displays more tuples than it contains its subnode - Mailing list pgsql-hackers

From Alena Rybakina
Subject Re: Sort operation displays more tuples than it contains its subnode
Date
Msg-id 55816aa0-a493-4ff3-a1c4-52948a809712@postgrespro.ru
Whole thread Raw
In response to Re: Sort operation displays more tuples than it contains its subnode  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers
Yes, I got it. Thank you very much for the explanation.

On 23.05.2024 00:17, Tom Lane wrote:
> "a.rybakina" <a.rybakina@postgrespro.ru> writes:
>> I faced the issue, when the sorting node in the actual information
>> shows a larger number of tuples than it actually is. And I can not
>> understand why?
> If I'm reading this correctly, the sort node you're worrying about
> feeds the inner side of a merge join.  Merge join will rewind its
> inner side to the start of the current group of equal-keyed tuples
> whenever it sees that the next outer tuple must also be joined to
> that group.  Since what EXPLAIN is counting is the number of tuples
> returned from the node, that causes it to double-count those tuples.
> The more duplicate-keyed tuples on the outer side, the bigger the
> effect.
>
> You can see the same thing happening at the Materialize a little
> further up, which is feeding the inside of the other merge join.

-- 
Regards,
Alena Rybakina
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: State of pg_createsubscriber
Next
From: Tom Lane
Date:
Subject: Re: about cross-compiling issue