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 1rGCWm-00ECTu-5i for pgsql-performance@arkaria.postgresql.org; Thu, 21 Dec 2023 06:27:28 +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 1rGCWk-004Eda-O5 for pgsql-performance@arkaria.postgresql.org; Thu, 21 Dec 2023 06:27:26 +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.94.2) (envelope-from ) id 1rGCWk-004EdG-Cz for pgsql-performance@lists.postgresql.org; Thu, 21 Dec 2023 06:27:26 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rGCWi-00BSDH-01 for pgsql-performance@lists.postgresql.org; Thu, 21 Dec 2023 06:27:25 +0000 Received: from [192.168.1.20] (lfbn-ren-1-1137-121.w92-139.abo.wanadoo.fr [92.139.85.121]) by mail.dalibo.com (Postfix) with ESMTPSA id 7BBED1F7CB; Thu, 21 Dec 2023 07:27:21 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1703140041; bh=tbantXoW39sTAEpq8C3KJ2EvVY2RHeFjbqN0oAdb3PM=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=IBdHwLyAb/okpWmktaiQLNJH+aF3AAvCT8/ZjKufKzP2c/XlHjwf8e0YiKkIo1Ja1 WfJnFKmE2w8MzQDBK3jCV9c0Ix7Jtu46QTHnxpZe6n0OCNgcKabPbFGMID4aUwchhq IHkUMn76ddJ8Oj3rCT3Vg6ZBRtFZ/uNh+r0VJYT8= Message-ID: <1834c776-cd1d-4669-89d9-5fb816acfd08@dalibo.com> Date: Thu, 21 Dec 2023 07:27:20 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Which side of a Merge Join gets executed first? Do both sides always get executed? Content-Language: fr, en-US To: Jerry Brenner Cc: pgsql-performance@lists.postgresql.org References: From: =?UTF-8?Q?Fr=C3=A9d=C3=A9ric_Yhuel?= Autocrypt: addr=frederic.yhuel@dalibo.com; keydata= xjMEXn3bgxYJKwYBBAHaRw8BAQdA6tX5FT/n5ztMWIoBdl6k5avvu65fv6ryfVzIx/aH3V3N JEYuIFlodWVsIDxmcmVkZXJpYy55aHVlbEBkYWxpYm8uY29tPsKWBBMWCAA+FiEEi7OTyf6H ePS+C6n11XGWhN8zGNUFAl6G6CYCGwMFCQeE3WIFCwkIBwIGFQoJCAsCBBYCAwECHgECF4AA CgkQ1XGWhN8zGNWH2wEA/YqoX3f4vTCknwEQgJtqWmcahkMKeusqdddqAB/jclQBAIKj3+N8 fj3S9ZASdfUUz+PoPBvuDSSTdOqwfjX9hZkNzjgEXn3bgxIKKwYBBAGXVQEFAQEHQCuh5cLQ AtEBXHa2Fmtp0kduBu7msM7qO/gaEcdjFUdiAwEIB8J+BBgWCAAmAhsMFiEEi7OTyf6HePS+ C6n11XGWhN8zGNUFAl596uUFCQeE3WIACgkQ1XGWhN8zGNVjGgEA8sKopTosiMWP+pbyf4jF 5WphrhyQf+EBlKIAs0eOpOABAMFDjT7cnlc72KVZd79jT3zmEoVq+IUW5QhcW03LnhoN In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Le 20/12/2023 à 20:04, Jerry Brenner a écrit : > Thanks.  Does this make sense? > > * There are 3 nodes under the Merge Join > * The first node is an InitPlan, due to the ANY(ARRAY()) - that gets > executed and finds 0 matching rows > * The second node is the outer node in the Merge Join and that is the > expensive node in our query plan > * The third node is the inner node in the Merge Join and that node > references the SubPlan generated by the first node. The IndexCond > has*"id = ANY($2) AND ..."* and the comparison with the result of > the SubPlan does not find a match, so that's where the > short-circuiting happens. I think it does. I'm not very experienced with the customs of these mailing lists, but I think the following would help to get more answers : * TEXT format of EXPLAIN is much more readable (compared to JSON) * A well formatted query would help * Screenshots aren't so great Rather than a screenshot, maybe you could use one of explain.depesz.com, explain.dalibo.com, or explain-postgresql.com ? Best regards, Frédéric