Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBDs6-0003kU-4V for pgsql-performance@arkaria.postgresql.org; Mon, 19 Jun 2023 12:20:38 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qBDs4-0006AY-Rw for pgsql-performance@arkaria.postgresql.org; Mon, 19 Jun 2023 12:20:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qBDs4-0006AG-6Y for pgsql-performance@lists.postgresql.org; Mon, 19 Jun 2023 12:20:36 +0000 Received: from mx0.riseup.net ([198.252.153.6]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qBDs0-003QAw-CZ for pgsql-performance@lists.postgresql.org; Mon, 19 Jun 2023 12:20:34 +0000 Received: from fews01-sea.riseup.net (fews01-sea-pn.riseup.net [10.0.1.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "mail.riseup.net", Issuer "R3" (not verified)) by mx0.riseup.net (Postfix) with ESMTPS id 4Ql83x4HSDz9t5v for ; Mon, 19 Jun 2023 12:20:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1687177229; bh=dANJMpMskHhqelwCpuMvIpwkWbBuVSbkdWz+5qHRkJw=; h=Subject:From:To:Date:In-Reply-To:References:From; b=FPmIPZ41NB4Ky776dSSsALMaidjFrvvyt8Y5Z13BAdnIdl3dnoEgAuF0idPWnyThA nNvPEiIePWgc6bA5x6ls6aSm5/dR8gJNO7o+xuec9NbvSGmSmDXHgKv7foujxDEnqv pQ5u/zPt8Bfju1PNFubjW/xSOoDwzF6q5IPyWkGE= X-Riseup-User-ID: 75B29E68DC09F8C24DAF9B6A0CA6792008C888C621FB754C224DA00CE3AB8127 Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews01-sea.riseup.net (Postfix) with ESMTPSA id 4Ql83w6WnpzJqCv for ; Mon, 19 Jun 2023 12:20:28 +0000 (UTC) Message-ID: Subject: Re: Merge David and Goliath tables efficiently From: nicolas paris To: pgsql-performance@lists.postgresql.org Date: Mon, 19 Jun 2023 14:20:26 +0200 In-Reply-To: <27cdb9c5-6dc7-87ff-303e-b0d0d20edbc4@enterprisedb.com> References: <20230619074646.2zlxxaqjieiafgqi@alvherre.pgsql> <27cdb9c5-6dc7-87ff-303e-b0d0d20edbc4@enterprisedb.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > IMHO the thing that breaks it is the ORDER BY in the merge, which > likely > acts as an optimization fence and prevents all sorts of smart things > including the partitionwise join. I'd bet that if Nicolas replaces >=20 > =C2=A0 MERGE INTO "goliath" ca > =C2=A0 USING (SELECT * FROM "david" ORDER BY "list_id") AS t > =C2=A0 . Sorry if it was not clear, however there is no order by in the 2.1 strategy. Then this cannot be the reason of not triggering the optim. For information I do enable partition join feature with jdbc call just before the merge: set enable_partitionwise_join=3Dtrue