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 1twqJw-000a8s-Fn for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 22:31:10 +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 1twqJf-00B2PF-HB for pgsql-hackers@arkaria.postgresql.org; Mon, 24 Mar 2025 22:30:43 +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 1twqJf-00B2P7-5f for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 22:30:43 +0000 Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1twqJc-000xLY-33 for pgsql-hackers@lists.postgresql.org; Mon, 24 Mar 2025 22:30:42 +0000 Received: by mail-lj1-x22c.google.com with SMTP id 38308e7fff4ca-30bfe0d2b6dso53922461fa.3 for ; Mon, 24 Mar 2025 15:30:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fittl.com; s=google; t=1742855440; x=1743460240; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=k+2fmfSQmNTy07LuHf+dmI0q69s4UaDgMvHIFUaNFy4=; b=fpzBxdNZJBn3oILQZQoGyoSlAhymGPsZo7CvJJP69BffzDMd43er98p5vcwMpw434j D3JbYPz5d/CbhL2hqOFaAr/rzZRI263DwYLFQ1Jed/hcyH8lUmDjJqhoj/vsZAc9aw3R TTVdRlQtaFR6lwqxkHfvlfMugOs4vbqiHpY4M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742855440; x=1743460240; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=k+2fmfSQmNTy07LuHf+dmI0q69s4UaDgMvHIFUaNFy4=; b=TH21zStLybPRNCb05FFDVOCD2M/4S9ZcbtcbpK+u7ygt/E5H6NYo7XD3YG+QqzQSSV wk+5mG8wfG80uWsGtmU9sheyIEar5dhiGlpn9zEpvh8ln95IDayhSJhmnCcFV9NnvO+a HDrYvkIIwGS7d+ZW0KSaWjueRIXmqmv0wQo7FtzdhW1cCqlLxtPpLv+PZzpbqoJTfOga ODxWeJI4HeIulPzB64sJJNy4SQxDMZbZkQS3vQTXNfQCRxRBmBf0NhqFDldImC6VVyKR dIR4yv8UYU37wZSRxXXE7tBDrbuOlVCAfzTjsKYTJthumvOjs5HEnwr0yWsLKIl6GVID tzZQ== X-Forwarded-Encrypted: i=1; AJvYcCVjmJQAVNFypibb/8gKP1NTTNOdGsiHAb3GHJ8Nbu8G7/8rgB5NoWQaTSzR7DauJCxtHc4dJ5u0uekAzVvV@lists.postgresql.org X-Gm-Message-State: AOJu0YxRunNSv1Syzdc+a/B6FYshDwVJFOpqoLtOc5EX02WJbtdGWmFi 8KsTKMWjCI0INUx+RvnjnX6uU8+DzBmgwi0dpUYJfPNQn1LgLYo++E3y1URzIJzhTiYeX45HyEp MEMS2ju0TE0B/kJGGoMV3dS4mgKH9Axg2qqkM X-Gm-Gg: ASbGncvl1mxDihV8ITUhMd1BqEVCY9wlp0AK2f+XKHG7SbM2FJ9Z4cP+184bSbCkoX7 mx6Xxl9jbCA4ZEFSe8z8CyBaVhJ1aiKMIsBnwA88tqZWJwha7LOzpsiRmXjy46SZAc3tsDMjdXx d4i5rKfyu2a78T5cQrrMOO+75JmSA= X-Google-Smtp-Source: AGHT+IEz0673akcuOKZqxo3Oa/fDhSQ3mDxvaiQ0SXuD45qgBpM2F+UKGfMc/cdW90dyCO8H9zSrrVa/hm4e5/oIlOM= X-Received: by 2002:a05:6512:e9b:b0:549:6bad:3977 with SMTP id 2adb3069b0e04-54ad6490ba3mr4784250e87.31.1742855439617; Mon, 24 Mar 2025 15:30:39 -0700 (PDT) MIME-Version: 1.0 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> <1161645.1742854534@sss.pgh.pa.us> In-Reply-To: <1161645.1742854534@sss.pgh.pa.us> From: Lukas Fittl Date: Mon, 24 Mar 2025 15:30:03 -0700 X-Gm-Features: AQ5f1JoxfS45SWFP0ipFbx_eWr6aFM6aHyjcUGxipY6SrcyqRLcaadXdAzBfkMM Message-ID: Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment To: Tom Lane Cc: David Rowley , Andrei Lepikhov , Ilia Evdokimov , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov Content-Type: multipart/alternative; boundary="0000000000005fb6c406311e278c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000005fb6c406311e278c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Mar 24, 2025 at 3:15=E2=80=AFPM Tom Lane wrote: > 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. > The main argument I had initially when proposing this, is that Memoize is different from other plan nodes, in that it makes the child node costs "cheaper". Clearly seeing the expected cache hit/ratio (that drives that costing modification) helps interpret why the planner came up with a given plan. Put differently, the reason this should be in the default EXPLAIN output (or at least the VERBOSE output), is because Memoize's impact on costing is counterintuitive (in my experience), and breaks the user's understanding of planner costs you can usually derive by looking at the per-node cost details, which typically flows up (i.e. gets larger as you step higher up in the tree). > > 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 don't think that addresses the end-user usability sufficiently - from what I gathered "pg_overexplain" was meant for a hacker audience, not DBAs/etc interpreting Postgres plan choices. Thanks, Lukas --=20 Lukas Fittl --0000000000005fb6c406311e278c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Mon, Mar 24, 2025 at 3:15=E2=80=AFPM T= om Lane <tgl@sss.pgh.pa.us> = wrote:
FWIW, I share these doubts about whethe= r these values are useful
enough to include in the default EXPLAIN output.=C2=A0 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.
The main argument I had initially when proposing this, is that= Memoize is different from other plan nodes, in that it makes the child nod= e costs "cheaper". Clearly seeing the expected cache hit/ratio (t= hat drives that costing modification) helps interpret why the planner came = up with a given plan.

Put differently, the reason = this should be in the default EXPLAIN output (or at least the VERBOSE outpu= t), is because Memoize's impact on costing is counterintuitive (in my e= xperience), and breaks the user's understanding of planner costs you ca= n usually derive by looking at the per-node cost details, which typically f= lows up (i.e. gets larger as you step higher up in the tree).
=C2= =A0

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 don= 9;t think that addresses the end-user usability sufficiently - from what I = gathered "pg_overexplain" was meant for a hacker audience, not DB= As/etc interpreting Postgres plan choices.

Thanks,
L= ukas

--
Lukas Fittl
--0000000000005fb6c406311e278c--