Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qRwRf-003gN7-OF for pgsql-performance@arkaria.postgresql.org; Fri, 04 Aug 2023 15:10:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qRwRd-008bSF-R7 for pgsql-performance@arkaria.postgresql.org; Fri, 04 Aug 2023 15:10:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qRwRd-008bS5-Hk for pgsql-performance@lists.postgresql.org; Fri, 04 Aug 2023 15:10:25 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qRwRb-000YhN-Lu for pgsql-performance@postgresql.org; Fri, 04 Aug 2023 15:10:25 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 374FALju3658473; Fri, 4 Aug 2023 11:10:21 -0400 From: Tom Lane To: Dane Foster cc: psql-performance Subject: Re: Plan weirdness. A sort produces more rows than the node beneath it In-reply-to: References: Comments: In-reply-to Dane Foster message dated "Fri, 04 Aug 2023 10:59:19 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <3658471.1691161821.1@sss.pgh.pa.us> Date: Fri, 04 Aug 2023 11:10:21 -0400 Message-ID: <3658472.1691161821@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Dane Foster writes: > I'm trying to understand a bit of weirdness in a plan output. There is a > sort node above a sequential scan node where the scan node produces 26,026 > rows yet the sort node above it produces 42,995,408. How is it possible to > sort more data than you received? If the sort is the inner input to a merge join, this could reflect mark-and-restore rescanning of the sort's output. Are there a whole lot of duplicate keys on the merge's other side? regards, tom lane