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 1uEVAN-0092Ae-Em for pgsql-performance@arkaria.postgresql.org; Mon, 12 May 2025 15:34:07 +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 1uEV9O-00H14r-2J for pgsql-performance@arkaria.postgresql.org; Mon, 12 May 2025 15:33:06 +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 1uEV9N-00H11N-Nm for pgsql-performance@lists.postgresql.org; Mon, 12 May 2025 15:33:05 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1uEV9L-001RhB-1D for pgsql-performance@lists.postgresql.org; Mon, 12 May 2025 15:33:04 +0000 Received: from pro.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 54CFX21N1315549; Mon, 12 May 2025 11:33:02 -0400 From: Tom Lane To: Maxim Boguk cc: David Rowley , Andrei Lepikhov , Pgsql Performance Subject: Re: inefficient/wrong plan cache mode selection for queries with partitioned tables (postgresql 17) In-reply-to: References: Comments: In-reply-to Maxim Boguk message dated "Mon, 12 May 2025 18:18:43 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <38200.1747063982.1@sss.pgh.pa.us> Date: Mon, 12 May 2025 11:33:02 -0400 Message-ID: <38201.1747063982@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Maxim Boguk writes: > And the problem is that the cost of a custom plan ignores the cost of > planning itself (which is like 2x orders of magnitude worse than the cost > of real time partition pruning of a generic plan). False. The estimate is evidently pretty wrong, but it's not that there is no consideration at all. See around line 1370 in src/backend/utils/cache/plancache.c. regards, tom lane