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 1tKCu5-007SUs-Qf for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Dec 2024 08:44:37 +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 1tKCu1-0014ck-8j for pgsql-hackers@arkaria.postgresql.org; Sun, 08 Dec 2024 08:44:34 +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 1tKCu0-0014cc-Tb for pgsql-hackers@lists.postgresql.org; Sun, 08 Dec 2024 08:44:34 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tKCtz-001drV-Au for pgsql-hackers@lists.postgresql.org; Sun, 08 Dec 2024 08:44:33 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-21636268e43so6231675ad.2 for ; Sun, 08 Dec 2024 00:44:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1733647470; x=1734252270; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=KGRh6t0N18Op/KC3WI4WSfRF6mBlROSJrPu4HVHB+SA=; b=OjJ1aiL3nrTP3cY0KsQ3/iowzeJDGXizUS2Ba1TtnhpulGj5iahZdj4Ysa40mk5K4c F2hkp5+o7Z3PC1UoW7wntmBBaZWl5Js831y8MISd3FMyAeRzcpnKRxTK85jlqX9HCs94 hMTaVb+EtnMLDwcDfGvXiiwC3SFW1QP60d5BtdM89SbabSiHQKSAyuDpsmBOQ+5Ti20H HkD876tRu+Yv9VcOFolFzp2mJz0sJNXX2ZCmnAjPfwemRA2Px4moYMbxT4xc9yP1O8B7 lyWMUVGCfIhhWv12vaPbL5CU5Ku6av1YE5Ro9KmHBpdj70VRPGo2P41HkFFmZ39xQMOp lfuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733647470; x=1734252270; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=KGRh6t0N18Op/KC3WI4WSfRF6mBlROSJrPu4HVHB+SA=; b=WO5XQrEXYwumtTEDB8slV7g+gjohBHwJinG/ymyilaHhVdzdBzK1kVbeH9hH7bmAb9 BkIua4gSXSjDk4t098Clc/uVh9tSSIKCzKtGVUPzd2g0TWu1S3S2fR/uBxaZDiubvO4B kBhzLJBNANBZpbOgnG6xK5pc7wogT6P2B4bigIr6EH/KVxzbiC5/sWRD2hHE50rrPJaV tRzk7/xGg1DXVull9jwuNGg4jCnnSl8pBQM3G9R5x4tWeNWHNqKt8uarBeiAD3CXgy5k JMYnkoy3nysWwu8rhoMbKiWdLWRKMr05HO2Hutp2laDNLTQIDR7EZBbUjT3PEBCesQjk ko+w== X-Forwarded-Encrypted: i=1; AJvYcCXFZ1WEIaVBdKEGEyxwX911EgMBSveoqqNA1HTjA6X+Kki3pEoj0wESkSxtV+piDcy6uFbiC7AESo04egCa@lists.postgresql.org X-Gm-Message-State: AOJu0YwlZ9PqpaJw0yOu4djL9ys8c+IYImyoasfiC7sMFz55XpQTK8IP tZ81qaOsRvEfMYiKwrEVIfvCbqBAiwrjr8uhUY7cKxQ2IN54xheQ X-Gm-Gg: ASbGncuFT+s4XYo3DS65FV3qQH1u84f3ZOoXMtk4+cZVwZLZ3FFglsxDj/ZWDGCmMw+ wPo6GckKESDxSTs+2yCubAO1/mscAhQARnZ5jonHDdBLDyHd6m0IgCm2g9VWTMDPvo3dUtLuMJK 70gF+4oMk+45O5XBM1PGK/bn2ligzrGTPk9LoH4yXEIEqaw2Oll04afW7V0+T+JNzvvxq+ET6fn c7m0fSnjwGZCc29Ypka5P/hZX/YU6pL0/jpfg5QwhZPDt/vrY5oSHiVjvpjeajTbxA6HX4qqTKg Xb0/QJ6wld+pj+p1uth5sQyM60Q= X-Google-Smtp-Source: AGHT+IG1y7sreKzREDA5/9/sWlqTiAAe+SsLHbC4TH/i3Nmqr4Xn9FJGvTSM1yRt8PEkY7tq3DDWyw== X-Received: by 2002:a17:902:e88f:b0:215:7fad:49ab with SMTP id d9443c01a7336-21614d1a6ecmr130906935ad.10.1733647469530; Sun, 08 Dec 2024 00:44:29 -0800 (PST) Received: from [192.168.1.45] (cm-27-145-178-18.revip12.asianet.co.th. [27.145.178.18]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-21641f46e17sm6086275ad.221.2024.12.08.00.44.27 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 08 Dec 2024 00:44:28 -0800 (PST) Message-ID: <19969d0d-769c-42df-9ae5-3ca4ef2f44d0@gmail.com> Date: Sun, 8 Dec 2024 15:44:23 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Do not scan index in right table if condition for left join evaluates to false using columns in left table To: Andres Freund Cc: Tom Lane , =?UTF-8?B?0JjQu9GM0Y8g0JbQsNGA0LrQvtCy?= , pgsql-hackers@lists.postgresql.org, p.petrov@postgrespro.ru References: <3510224.1733609212@sss.pgh.pa.us> <3517444.1733613195@sss.pgh.pa.us> <07d035c5-0e40-45ee-9c78-60a5dc6e9fae@gmail.com> Content-Language: en-US From: Andrei Lepikhov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 8/12/2024 09:52, Andres Freund wrote: >> I think avoiding touching a hash table and an index under MergeJoin can also >> be beneficial. > > How would you get significant wins for mergejoins? You need to go through both > inner and outer anyway? In my mind, this trick can be designed for specific cases like sales tables, as illustrated before and used by well-rounded developers. I'm not sure that such optimisation would be profitable in general. My point is that the sales database has lots of categories, and when requesting product descriptions, we will not necessarily touch all the categories - in that case, the one-sided clause could allow us to avoid scanning some tables at all. Am I wrong? BTW, may it be used in SEMI JOIN cases? -- regards, Andrei Lepikhov