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 1raoev-00Bamo-4a for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 03:13:05 +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 1raoet-00GuER-Fo for pgsql-hackers@arkaria.postgresql.org; Fri, 16 Feb 2024 03:13:03 +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 1raoet-00GuEI-1U for pgsql-hackers@lists.postgresql.org; Fri, 16 Feb 2024 03:13:03 +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 1raoek-006ypa-W5 for pgsql-hackers@postgresql.org; Fri, 16 Feb 2024 03:13:01 +0000 Received: from [192.168.1.58] (unknown [1.20.175.84]) (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 A95A5E21104; Fri, 16 Feb 2024 06:12:50 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1708053171; bh=OdEaHi8njOVaCSji4dxRrSmXmAGDUwJwZqWqpRw86b0=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=tG9Jg8nI7EkJ0FxlMRjKEvFoQ1iIznUSLaYAgSHCDnYhkZC1n2KFmmDlrYhEIKNAL IkNCk17XZLRf7ATgqcZz1mBf0QfxuQeUJWL8pQWRyh5g/EAS1KSADW2AUaaKaU1vf/ LwxbNxnm1JiQRo3wfOUyx5S+b11GQyknfodTu/Z+FGl6yNVexmpNj0j/5mP8hXB0/U yHFZjS65xzdvPhhnO+6ibDEmQO7qCMAF3wFaOajWsNvXmuFfzdQMJ9FE+ntL+7JXk5 ld+WQTQvFyILKjJvVoOEiMvXtS3ZJNZ0aJtHqWSEEgGZ0vwHOry0qErwvbHnisuayS 4kghR9AA4wSJw== Message-ID: <182fbad0-f3f6-4692-8fc4-778378e1db01@postgrespro.ru> Date: Fri, 16 Feb 2024 10:12:47 +0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Memory consumed by paths during partitionwise join planning Content-Language: en-US To: Ashutosh Bapat Cc: David Rowley , pgsql-hackers References: 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 15/2/2024 19:06, Ashutosh Bapat wrote: > On Thu, Feb 15, 2024 at 9:41 AM Andrei Lepikhov >> But I'm not sure about freeing unreferenced paths. I would have to see >> alternatives in the pathlist. > > I didn't understand this. Can you please elaborate? A path in any > pathlist is referenced. An unreferenced path should not be in any > pathlist. I mean that at some point, an extension can reconsider the path tree after building the top node of this path. I vaguely recall that we already have (or had) kind of such optimization in the core where part of the plan changes after it has been built. Live example: right now, I am working on the code like MSSQL has - a combination of NestLoop and HashJoin paths and switching between them in real-time. It requires both paths in the path list at the moment when extensions are coming. Even if one of them isn't referenced from the upper pathlist, it may still be helpful for the extension. >> About partitioning. As I discovered planning issues connected to >> partitions, the painful problem is a rule, according to which we are >> trying to use all nomenclature of possible paths for each partition. >> With indexes, it quickly increases optimization work. IMO, this can help >> a 'symmetrical' approach, which could restrict the scope of possible >> pathways for upcoming partitions if we filter some paths in a set of >> previously planned partitions. > > filter or free? Filter. I meant that Postres tries to apply IndexScan, BitmapScan, IndexOnlyScan, and other strategies, passing throughout the partition indexes. The optimizer spends a lot of time doing that. So, why not introduce a symmetrical strategy and give away from the search some indexes of types of scan based on the pathifying experience of previous partitions of the same table: if you have dozens of partitions, Is it beneficial for the system to find a bit more optimal IndexScan on one partition having SeqScans on 999 other? -- regards, Andrei Lepikhov Postgres Professional