Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyJdz-0004u2-53 for pgsql-performance@arkaria.postgresql.org; Tue, 29 Jun 2021 19:43:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1lyJdw-0006jW-Ml for pgsql-performance@arkaria.postgresql.org; Tue, 29 Jun 2021 19:43:36 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyJdw-0006jN-Eg for pgsql-performance@lists.postgresql.org; Tue, 29 Jun 2021 19:43:36 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lyJdu-0002tG-Jf for pgsql-performance@lists.postgresql.org; Tue, 29 Jun 2021 19:43:36 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 15TJhSY0500143; Tue, 29 Jun 2021 15:43:28 -0400 From: Tom Lane To: Manuel Weitzman cc: Ranier Vilela , David Rowley , Jeremy Schneider , "pgsql-performance@lists.postgresql.org" , Andres Freund Subject: Re: Planning performance problem (67626.278ms) In-reply-to: <39C2266C-3143-4A7A-BCAF-E0C8394F9D24@gmail.com> References: <6d58f68e-ed1a-c48e-1440-691554f6e1e7@9livesdata.com> <20190408144210.GG10080@telsasoft.com> <20190408232644.r6xixkeulsmomwfj@alap3.anarazel.de> <3f5e5673-06aa-bf7c-cdb7-0e053c45ba26@amazon.com> <767433.1619015825@sss.pgh.pa.us> <1588548.1624234651@sss.pgh.pa.us> <39C2266C-3143-4A7A-BCAF-E0C8394F9D24@gmail.com> Comments: In-reply-to Manuel Weitzman message dated "Tue, 29 Jun 2021 15:26:20 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <500141.1624995808.1@sss.pgh.pa.us> Date: Tue, 29 Jun 2021 15:43:28 -0400 Message-ID: <500142.1624995808@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Manuel Weitzman writes: >> On 20-06-2021, at 17:06, Tom Lane wrote: >> So ... the reason why there's not caching of get_actual_variable_range >> results already is that I'd supposed it wouldn't be necessary given >> the caching of selectivity estimates that happens at the RestrictInfo >> level. I don't have any objection in principle to adding another >> caching layer if that one's not working well enough, but I think it'd >> be wise to first understand why it's needed. > For what I could make out from the code, the caching done at the > RestrictInfo level is already saving a lot of work, but there's a > different RestrictInfo instance for each alternative path created by > make_one_rel(). That seems a bit broken; a given WHERE clause should produce only one RestrictInfo. Can you provide a more concrete example? regards, tom lane