Received: from [217.196.149.56] (helo=malur.postgresql.org) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1twq5I-000ZlX-6M for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 22:15:52 +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 1twq56-00AsQv-Sd for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 22:15:40 +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 1twq56-00AsQ6-Ih for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 22:15:40 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1twq54-000xEF-10 for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 22:15:40 +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 52OMFYHv1161646; Mon, 24 Mar 2025 18:15:34 -0400 From: Tom Lane To: David Rowley cc: Andrei Lepikhov , Ilia Evdokimov , Lukas Fittl , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment In-reply-to: References: <51A15CD7-E31B-483D-B911-D0EB9F5FF952@yesql.se> <44229379-3901-4cb0-8812-b354ef70d5e2@gmail.com> <8e12aa55-39eb-4e03-a8f7-077fe02309c3@gmail.com> <11c709e1-9b17-4c00-9ead-93609a09b9db@gmail.com> Comments: In-reply-to David Rowley message dated "Tue, 25 Mar 2025 11:05:16 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1161644.1742854534.1@sss.pgh.pa.us> Date: Mon, 24 Mar 2025 18:15:34 -0400 Message-ID: <1161645.1742854534@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > I'm not following what the -1 is for. Is it for showing both hit and > evict ratios? And your vote is only for adding hit ratio? > Just to make it clear, the evict ratio isn't redundant because we show > hit ratio. If you have 1000 calls and 1000 distinct values and enough > memory to store those, then that's a 0% hit ratio since the first > lookup is a miss. If you change the calls to 2000 then that's a 50% > hit ratio and still 0% evict. FWIW, I share these doubts about whether these values are useful enough to include in the default EXPLAIN output. My main beef with them though is that they are basically numbers derived along the way to producing a cost estimate, and I don't think we break out such intermediate results for other node types. It's looking like Robert's "pg_overexplain" will hit the tree soon, so maybe there could be a case for teaching that to emit additional costing details such as these? I'd kind of like to see a larger scope than just Memoize for such an addition, though I'm not sure exactly which other intermediate estimates are worth showing. regards, tom lane