Vitaliy Garnashevich <vgarnashevich@xxxxxxxxx> writes: > How, according to EXPLAIN ANALYZE, the Sort node could return more rows > as output (rows=767662), than it had for input from its child node > (rows=135627)? Unsurprising when it's the inner input of a merge join --- that reflects the merge join rescanning parts of the inner input. It has to do that whenever the outer input has duplicate keys. regards, tom lane