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.96) (envelope-from ) id 1wI3O5-007kTq-2E for pgsql-performance@arkaria.postgresql.org; Wed, 29 Apr 2026 11:47:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wI3O3-003ICv-1x for pgsql-performance@arkaria.postgresql.org; Wed, 29 Apr 2026 11:47:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wI3O3-003ICm-0p for pgsql-performance@lists.postgresql.org; Wed, 29 Apr 2026 11:47:27 +0000 Received: from out-03.pe-bsn.jellyfish.systems ([66.29.159.81]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wI3O0-00000003L7Z-2Mcr for pgsql-performance@postgresql.org; Wed, 29 Apr 2026 11:47:26 +0000 Received: from MTA-15.privateemail.com (unknown [10.50.14.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by BSN-02.privateemail.com (Postfix) with ESMTPS id 4g5FsQ2P80z3hhTG; Wed, 29 Apr 2026 07:47:22 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=viktorh.net; s=default; t=1777463242; bh=qbX6Vlh6Qa76AK3p/wKVl+kcFEOMFPZv73lTL/FyObo=; h=Date:From:To:Cc:In-Reply-To:References:Subject:From; b=KYbSw2TMXrzImq6BgSt34QoPsSNTIo6OCis0tavd4u3ZcjJr+sDbgyfZ/IvHOWNGM IkMSmC3me1HN83wFdJcRsFOFkXo/KZEk2x96PE5iLGGGMIsaz4TbQoEg6Sg1cnEbx+ bx0MNCe1OXFxW+g3Du9VgC6MARAztnA34x9iSHy5zWy/aRx/gk+LDLWEPVI09vVTnr 3avcQf9yPAU/8VYmQOsspngNvdB8lXVFbIGoUBv+BsKjQ0fmM5SeCdbQOoHHvJ/1UJ IGEnQtcfouLvIPCYOo9XQYO2ZYanD+1s+MYfBieMsbZT1JIwNs6g8nhEFi8YauYf+T rL5ZvYr5V1nXQ== Received: from mta-15.privateemail.com (localhost [127.0.0.1]) by mta-15.privateemail.com (Postfix) with ESMTP id 4g5FsQ1FMTz3hhT9; Wed, 29 Apr 2026 07:47:22 -0400 (EDT) Received: from [192.168.0.130] (c188-151-222-15.bredband.tele2.se [188.151.222.15]) by mta-15.privateemail.com (Postfix) with ESMTPA; Wed, 29 Apr 2026 07:47:19 -0400 (EDT) Date: Wed, 29 Apr 2026 13:47:07 +0200 From: Viktor Holmberg To: Feike Steenbergen , David Mullineux Cc: pgsql-performance@postgresql.org Message-ID: In-Reply-To: References: Subject: Re: Unexpected Seq Scan's when using MERGE WHEN NOT MATCHED BY SOURCE X-Readdle-Message-ID: fffd3a77-f9cb-44e5-91ea-11d6216f3f14@Spark MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="69f1efc3_3a95f874_7e8e" X-Virus-Scanned: ClamAV using ClamSMTP List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --69f1efc3_3a95f874_7e8e Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Apologies for the necromancer here but just chiming in that I also got bi= tten by this in our production systems today. It=E2=80=99s precisely the = same pattern - MERGEing into a =E2=80=9Cpart=E2=80=9D of a table. Would b= e nice if MERGE allowed you to specify a =E2=80=9Cfilter=E2=80=9D or some= thing so it only affected a subsection of the table - but Toms suggestion= of pushing down the condition would also have saved me. =46or now I=E2=80= =99m just going to have to abandon the MERGE construct and go back to sep= arate INSERT and DELETE=E2=80=99s. /Viktor --69f1efc3_3a95f874_7e8e Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline
Apologies for the necromancer here but just chiming= in that I also got bitten by this in our production systems today. It=E2= =80=99s precisely the same pattern - MERGEing into a =E2=80=9Cpart=E2=80=9D= of a table. Would be nice if MERGE allowed you to specify a =E2=80=9Cfil= ter=E2=80=9D or something so it only affected a subsection of the table -= but Toms suggestion of pushing down the condition would also have saved = me. =46or now I=E2=80=99m just going to have to abandon the MERGE constru= ct and go back to separate INSERT and DELETE=E2=80=99s.&=23160;

/Viktor
--69f1efc3_3a95f874_7e8e--