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 1rrUW1-000vh6-O4 for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 03:08:51 +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 1rrUV1-003xCU-6a for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 03:07:47 +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 1rrUV0-003xCM-PG for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 03:07:47 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrUUw-0005FY-2h for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 03:07:46 +0000 Received: from [172.30.8.38] (unknown [172.30.8.38]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: a.lepikhov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id E86D7E20C32; Tue, 2 Apr 2024 06:07:37 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1712027260; bh=GZtxAsJtPgZaIG6wmT8OKpW6mk3tcy962XFU5fBCvJI=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=ya10CmV8cnHv/ZMqwCpSGfl78xg0MLMzW0o2JPqlK1lsujUBId8AD+PPpA6sy/hIh c+mltnT3Ux54V+YdYFs1n3fC2lPqGoDc2AfJznpqFnw9Rs3CWKk53I1vymRWQIfl8H 2cV924AtEzlX4khQ/NZ+m8Rr9HpfScfVJQxnFT+z7R6bLepof8g4eWxXwGmP78xuAX XeS8OfKqlD4khlHdVolp96dQ6sMAnMuhC5jnXoBuJx8i5tyzttob469XFFT7E9tHHB H5R60Il6JKFdWxWsWTlRfbGdvcqDWTW3l72UoozgboGEF26CkH4z1XyKySJunQCC1A HUjEWkqHSkjFw== Message-ID: Date: Tue, 2 Apr 2024 10:07:35 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Asymmetric partition-wise JOIN To: Alexander Korotkov , Thomas Munro , KaiGai Kohei , sulamul@gmail.com Cc: Alexander Pyhalov , Jaime Casanova , Aleksander Alekseev , pgsql-hackers@lists.postgresql.org, "a.rybakina" References: <163118104689.1167.8241611097516113795.pgcf@coridan.postgresql.org> <20210909153833.GA6514@ahch-to> <2c9caede-55c0-2042-e421-dd0021f28837@postgrespro.ru> <792d60f4-37bc-e6ad-68ca-c2af5cbb2d9b@postgrespro.ru> <88bc3c051d285653215393a56bdf3056@postgrespro.ru> <5c0e38e3-7ab5-4b10-a1bb-70ca69771ff0@postgrespro.ru> Content-Language: en-US From: Andrei Lepikhov Organization: Postgres Professional 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 15/10/2023 13:25, Alexander Korotkov wrote: > Great! I'm looking forward to the revised patch. Revising the code and opinions before restarting this work, I found two different possible strategies mentioned in the thread: 1. 'Common Resources' shares the materialised result of the inner table scan (a hash table in the case of HashJoin) to join each partition one by one. It gives us a profit in the case of parallel append and possibly other cases, like the one shown in the initial message. 2. 'Individual strategies' - By limiting the AJ feature to cases when the JOIN clause contains a partitioning expression, we can push an additional scan clause into each copy of the inner table scan, reduce the number of tuples scanned, and even prune something because of proven zero input. I see the pros and cons of both approaches. The first option is more straightforward, and its outcome is obvious in the case of parallel append. But how can we guarantee the same join type for each join? Why should we ignore the positive effect of different strategies for different partitions? The second strategy is more expensive for the optimiser, especially in the multipartition case. But as I can predict, it is easier to implement and looks more natural for the architecture. What do you think about that? -- regards, Andrei Lepikhov Postgres Professional