From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "a(dot)rybakina" <a(dot)rybakina(at)postgrespro(dot)ru> |
Cc: | PostgreSQL Developers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: Sort operation displays more tuples than it contains its subnode |
Date: | 2024-05-22 21:17:48 |
Message-ID: | 19449.1716412668@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
"a.rybakina" <a(dot)rybakina(at)postgrespro(dot)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, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Martijn Wallet | 2024-05-22 21:29:31 | Re: processes stuck in shutdown following OOM/recovery |
Previous Message | David Rowley | 2024-05-22 21:08:35 | Re: Sort operation displays more tuples than it contains its subnode |