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 1qsz3n-00ALJL-E3 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Oct 2023 05:25:35 +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 1qsz3k-00HNf7-T1 for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Oct 2023 05:25:33 +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 1qsz3k-00HNeq-Ij for pgsql-hackers@lists.postgresql.org; Wed, 18 Oct 2023 05:25:33 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qsz3h-001J8d-6E for pgsql-hackers@lists.postgresql.org; Wed, 18 Oct 2023 05:25:32 +0000 Received: from [10.10.20.108] (node-q5w.pool-101-109.dynamic.totinternet.net [101.109.132.116]) (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 B88E6E203CB; Wed, 18 Oct 2023 08:25:26 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1697606729; bh=TtRePiD28D4pSAIPnH0CbZmUFavMY3XKMZPVkI4eKD4=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=dLqN5b7hYrKY0Tdwd2QVayb7V6ydUL5uJk2hbsFuYFsfzHgj16I2YwIMH21EVDiGe 4NSiFrEOZf1mfOzKWvxTiwbSs62W5BWreRGzmzGu0K/0o2p1cK+vqFdjGnxm3g+lih Zdvst0K5jV632Bt6djf1A4F1pIxGQ3RO26a96m6EpuLNf9TFobwkcP30UX4q1Xf3Xd TfLDg7eBf2C9p9MHEflLv040OTeGQK+Y+2dBhcqABzY19tcXlV3DLRmwSZlBUWomqt BA/NXUru8gClyDBV0xqQpi8niX/QHqykCkbK5elwxH2puV8vQavQhc3b37a9QsGxAv xcHguIeXDrNkQ== Message-ID: Date: Wed, 18 Oct 2023 12:25:23 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Asymmetric partition-wise JOIN Content-Language: en-US To: Ashutosh Bapat Cc: Alexander Korotkov , Alexander Pyhalov , Jaime Casanova , Aleksander Alekseev , pgsql-hackers@lists.postgresql.org, KaiGai Kohei , "a.rybakina" , =?UTF-8?B?0JHQtdC70Y/Qu9C+0LIg0JTQsNC80LjRgCDQndCw0LjQu9C10LLQuNGH?= 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> <521c2a71-49dd-4ab5-a585-569d0af3a647@postgrespro.ru> From: Andrei Lepikhov Organization: Postgres Professional 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 On 17/10/2023 17:09, Ashutosh Bapat wrote: > On Tue, Oct 17, 2023 at 2:05 PM Andrei Lepikhov > wrote: >> >> On 16/10/2023 23:21, Ashutosh Bapat wrote: >>> On Mon, Oct 16, 2023 at 10:24 AM Andrei Lepikhov >>> Whenever I visited this idea, I hit one issue prominently - how would >>> we differentiate different scans of the non-partitioned relation. >>> Normally we do that using different Relids but in this case we >>> wouldn't be able to know the number of such relations involved in the >>> query unless we start planning such a join. It's late to add new base >>> relations and assign them new Relids. Of course I haven't thought hard >>> about it. I haven't looked at the patch to see whether this problem is >>> solved and how. >>> >> I'm curious, which type of problems do you afraid here? Why we need a >> range table entry for each scan of non-partitioned relation? >> > > Not RTE but RelOptInfo. > > Using the same example as Alexander Korotkov, let's say A is the > nonpartitioned table and P is partitioned table with partitions P1, > P2, ... Pn. The partitionwise join would need to compute AP1, AP2, ... > APn. Each of these joins may have different properties and thus will > require creating paths. In order to save these paths, we need > RelOptInfos which are indentified by relids. Let's assume that the > relids of these join RelOptInfos are created by union of relid of A > and relid of Px (the partition being joined). This is notionally > misleading but doable. Ok, now I see your disquiet. In current patch we have built RelOptInfo for each JOIN(A, Pi) by the build_child_join_rel() routine. And of course, they all have different sets of cheapest paths (it is one more point of optimality). At this point the RelOptInfo of relation A is fully formed and upper joins use the pathlist "as is", without changes. > But the clauses of A parameterized by P will produce different > translations for each of the partitions. I think we will need > different RelOptInfos (for A) to store these translations. Does the answer above resolved this issue? > The relid is also used to track the scans at executor level. Since we > have so many scans on A, each may be using different plan, we will > need different ids for those. I don't understand this sentence. Which way executor uses this index of RelOptInfo ? -- regards, Andrey Lepikhov Postgres Professional