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 1tzWQi-003Aac-KC for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 07:53:04 +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 1tzWQg-00HFTg-GJ for pgsql-hackers@arkaria.postgresql.org; Tue, 01 Apr 2025 07:53:02 +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 1tzWQg-00HFTY-0v for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 07:53:02 +0000 Received: from forward502b.mail.yandex.net ([178.154.239.146]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tzWQc-002IMs-2I for pgsql-hackers@lists.postgresql.org; Tue, 01 Apr 2025 07:53:01 +0000 Received: from mail-nwsmtp-smtp-production-main-55.sas.yp-c.yandex.net (mail-nwsmtp-smtp-production-main-55.sas.yp-c.yandex.net [IPv6:2a02:6b8:c23:2db2:0:640:9334:0]) by forward502b.mail.yandex.net (Yandex) with ESMTPS id 827C2612FE; Tue, 1 Apr 2025 10:52:54 +0300 (MSK) Received: by mail-nwsmtp-smtp-production-main-55.sas.yp-c.yandex.net (smtp/Yandex) with ESMTPSA id qqQfLSI1QuQ0-1pwmumnS; Tue, 01 Apr 2025 10:52:53 +0300 X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tantorlabs.com; s=mail; t=1743493973; bh=WAQTMyefIiULyncKJB4/0SUM6sIkeXoiXV3pmYD+cfQ=; h=In-Reply-To:Cc:Date:References:To:From:Subject:Message-ID; b=I19pLS1XC1pVZSiH/KNLDaVgN5hK1s+0D8qhxexkftOn4WNJ4G+JDgikMtk+udr67 wNqAKxDS8p6fngTbLJUcb//1esQeeQ82UEKgkocA+1PvCc+duNCX14yuhlcPQw+zUC PA33ssINVJaMH1awm5rHK/5d1WdSsKoy7K5IxPno= Authentication-Results: mail-nwsmtp-smtp-production-main-55.sas.yp-c.yandex.net; dkim=pass header.i=@tantorlabs.com Message-ID: <580fe72c-85be-45a8-9e00-6b5417690557@tantorlabs.com> Date: Tue, 1 Apr 2025 10:52:52 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment From: Ilia Evdokimov To: Robert Haas , Tom Lane , David Rowley Cc: Lukas Fittl , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov , Andrei Lepikhov References: <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> <1164845.1742856354@sss.pgh.pa.us> <3ba16aa7-3cb2-4289-b773-522ae2f03a77@tantorlabs.com> <81ef0f5a-b6a1-4417-ae3a-2bae9b8d419e@gmail.com> <67b5c84a-dedd-4103-af7e-0117046102fe@tantorlabs.com> Content-Language: en-US In-Reply-To: <67b5c84a-dedd-4103-af7e-0117046102fe@tantorlabs.com> 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 28.03.2025 15:20, Ilia Evdokimov wrote: > Then we need to decide clearly what exactly to display in EXPLAIN for > the Memoize node: absolute values (estimated distinct keys and > estimated cache capacity) or ratios (hit_ratio and evict_ratio). > Ratios have the advantage of quickly reflecting the overall > effectiveness of Memoize. However, absolute values have a significant > advantage as they explicitly reveal the reason of Memoize's poor > performance, making problem diagnosis simpler. > > With absolute values, users can directly understand the underlying > reason for poor performance. For example: insufficient memory > (capacity < distinct keys), inaccurate planner statistics (distinct > keys significantly different from actual values), poorly ordered keys > (capacity ~ distinct keys, but frequent evictions as seen in the > Evictions parameter), or Memoize simply not being beneficial (capacity > ~ distinct keys ~ calls). Ratios, by contrast, only reflect the final > outcome without clearly indicating the cause or the specific steps > needed to resolve the issue. > > Thus, absolute values do more than just inform users that a problem > exists; they provide actionable details that enable users to directly > address the problem (increase work_mem, refresh statistics, create > extended statistics, or disable Memoize entirely). Additionally, no > other plan nodes in PostgreSQL currently use a similar ratio-based > approach - everywhere else absolute values are consistently shown > (e.g., number of rows, buckets, batches, memory used, etc.). Using > absolute values in Memoize maintains consistency with existing practice. > > I've updated the patch to v5, since the new parameter est_unique_keys > in make_memoize() is now placed near est_entries, which is more > logical and readable than putting it at the end. > > Any thoughts? > > -- > Best Regards, > Ilia Evdokimov, > Tantor Labs LLC. With the feature freeze coming up soon, I’d like to ask: do we plan to include this patch in v18? Please let me know if there’s anything I can do to help move it forward. -- Best regards, Ilia Evdokimov, Tantor Labs LLC.