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 1ra8c0-008FKL-1U for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Feb 2024 06:19:16 +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 1ra8b0-004Cch-9G for pgsql-hackers@arkaria.postgresql.org; Wed, 14 Feb 2024 06:18:14 +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 1ra8az-004CcZ-Rm for pgsql-hackers@lists.postgresql.org; Wed, 14 Feb 2024 06:18:14 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ra8aw-006f98-8e for pgsql-hackers@postgresql.org; Wed, 14 Feb 2024 06:18:12 +0000 Received: from [172.30.0.166] (unknown [172.30.0.166]) (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 CEE81E2104D; Wed, 14 Feb 2024 09:18:05 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1707891486; bh=9iSXrCESknsJyoV2IBmNHd/uwXr0b0oPasQ+CuupKrQ=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=Yoh5kDenvz+i8pHin/IcjcJ3PtDFFYkzzj1jho8qjFOayLZnkNduiR0qJ5tOQWmUe gIISHnUONJ95s0uPnpmW8FuwQ7i8j15wx8HE5/xVp8qMGgVvP5JZzMzdH/CGLuVZJs Q7per+RgPLhFc5d3Mfmgs36qxlxCwezpx3OUohUeM7S4mKLWyZvGwzLlo4jiMzEM3S C6JQoEsXuY10SynFrRj+bvW1jI9VB46yDHiYyWDaRpHun5bp3APGeXF6no8td7GDd5 ccR/egFghFjGcBJDHvd3ZrzxzlPM9ht0iiPLQLY/ToXfffbUQ/syv8Elc1SUOPwd1j YsLn6s1WueW5w== Message-ID: Date: Wed, 14 Feb 2024 13:18:02 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Propagate pathkeys from CTEs up to the outer query To: Richard Guo , PostgreSQL-development Cc: Tom Lane References: 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: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 29/1/2024 10:18, Richard Guo wrote: > In [1] we've reached a conclusion that for a MATERIALIZED CTE it's okay > to 'allow our statistics or guesses for the sub-query to subsequently > influence what the upper planner does'.  Commit f7816aec23 exposes > column statistics to the upper planner.  In the light of that, here is a > patch that exposes info about the ordering of the CTE result to the > upper planner. > > This patch was initially posted in that same thread and has received > some comments from Tom in [2].  Due to the presence of multiple patches > in that thread, it has led to confusion.  So fork a new thread here > specifically dedicated to discussing the patch about exposing pathkeys > from CTEs to the upper planner. I like this approach. It looks good initially, but such features need more opinions/views/time to analyse corner cases. It goes alongside my current backburner - pull parameterisation through the GROUP-BY and the query block fence up to the JOIN searching code of the parent query. -- regards, Andrei Lepikhov Postgres Professional