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 1txmcq-00EcKk-A4 for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Mar 2025 12:46:24 +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 1txmco-005jbV-Qf for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Mar 2025 12:46:22 +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 1txmco-005jYe-G4 for pgsql-hackers@lists.postgresql.org; Thu, 27 Mar 2025 12:46:22 +0000 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1txmcm-001QgZ-0o for pgsql-hackers@lists.postgresql.org; Thu, 27 Mar 2025 12:46:21 +0000 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-abbb12bea54so188813166b.0 for ; Thu, 27 Mar 2025 05:46:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743079579; x=1743684379; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=mB8g/EakTNzoFHpR76fNRKHZZnGxonIhn2Ms7XQUOMY=; b=NIfsyRzWsISvtbrcWeXrQEjvBC6FsTRiVJJOrSUwpeKt6hIu1+N5PAxXdZ2VxwtoNa MoS46cA+at6SKq/UUi/D3t3HD4xVz2k9KDjyv1+xJ9M2F/CmCKQwHbgXV/hvlxnfYomp +Sbb4VpzUvpZsTeLGI0ZWnOC1YpJVp0uU6/kAKytHHS4wPA/4z4gXPyKDDPXEZH9XOv5 3n1YbFHVjyE4mEdmeMExDh1V+3oxb6d2xRG4aSASjNdPQsrx4BXLaM+sg1FkU/AdOfxJ SxhVD/i1pz4cQjwSEJIFgF/gpG+vNeOf30AxrtvxU22jGej/u4ISGGieboTv0ocgH4ii iRAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743079579; x=1743684379; h=content-transfer-encoding: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=mB8g/EakTNzoFHpR76fNRKHZZnGxonIhn2Ms7XQUOMY=; b=EpNnWQwR1LiYljJA23G9/78QXpcM7+gq3vim7M92BQFOLuclJizTKmeIdV94SJa4m6 o+pgX/nDD5iCqNgtKG8yEwjl/7Yy7OUHcexkf4i1O3Ts56oOUo++sXoxKsbYwATwo31o MwUHLD/WjFjeIvs9aDUeZXpfcrjAMP4ewQF+Qb0p5YtXr42XXmbusySeEmVWl5lYEVlG 1UfD1oxyvA2zHeElHw7ih2uhTlobDeYcdPXkTyg45/VG5fsGaDWEJPvDzjFCbnHA3hxJ PiyBmUZTaS2YUxt0Iw8y+taLiHeyfpAvfHGViaWKgR6orOMOoNeQLIGLwio9B/4gn12G 60VQ== X-Forwarded-Encrypted: i=1; AJvYcCW04eo630dj8oFKUa+dnhsEWcn3qZvkUBMgbJX6F09lTrQ+3g8Tomj45g67EUT4drSrWU4zsbobIEKv0sJe@lists.postgresql.org X-Gm-Message-State: AOJu0Yw8/Wgmv/8CnV/7AmizwPqrfMN/Ghz8hVDEFQF6vegSi7ag2sE7 w1wP8SnI6NHQXFCIz6iJwA9jTHqNG3ju4Xg7ClVK19/i58bMUWGLCWZIcynDdwJrHu/RpKjLtgd Av7rAMU9SA1TRleDcXSeJeseQkyY= X-Gm-Gg: ASbGncvLmKewfnDLhFSw9EqnKwPzJ9BQnMFp6UElb86jGtOUs/7ewtfTwztORgXK05Y l2nzXz+ntRHhL9iwD9kfoeGFBZDic4oUL3EJ5MWrLvHLavZ3nTQXtoJG4n+PmDVI2BYYW+aFO3j 1jh6IbMhO/FiUMLKccw/9v6TtBUA== X-Google-Smtp-Source: AGHT+IFVuenshsBno2+DQz26Q3+h0YL4qVseVbtLSjX/4VqxuZyzUs4uZ+8jFLVufyfxCLOBqfOYf/1S3AbAPnxs2XU= X-Received: by 2002:a17:907:c1b:b0:ac6:b853:d07f with SMTP id a640c23a62f3a-ac6fae47566mr349165366b.2.1743079578422; Thu, 27 Mar 2025 05:46:18 -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> <1164845.1742856354@sss.pgh.pa.us> <3ba16aa7-3cb2-4289-b773-522ae2f03a77@tantorlabs.com> In-Reply-To: <3ba16aa7-3cb2-4289-b773-522ae2f03a77@tantorlabs.com> From: Robert Haas Date: Thu, 27 Mar 2025 08:46:07 -0400 X-Gm-Features: AQ5f1JqOzoBhBp4tAKSc9VC7_E9AhfV7Ntbo3zrxduSRy2tuPgEj0OHHembsFKQ Message-ID: Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment To: Ilia Evdokimov Cc: Tom Lane , Lukas Fittl , David Rowley , Andrei Lepikhov , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Mar 27, 2025 at 6:12=E2=80=AFAM Ilia Evdokimov wrote: > I understand the concerns raised about the risk of opening the door to mo= re diagnostic detail across various plan nodes. However, in Hash Join, Merg= e Join, and Nested Loop, EXPLAIN typically reveals at least some of the pla= nner=E2=80=99s expectations. For example, Hash Join shows the number of bat= ches and originally expected buckets, giving insight into whether the hash = table fit in memory. Merge Join shows unexpected Sort nodes when presorted = inputs were assumed. Nested Loop reflects planner assumptions via loops and= row estimates. In other words, these nodes expose at least some informatio= n about what the planner thought would happen. > > Memoize is unique in that it shows runtime statistics (hits, misses, evic= tions), but reveals nothing about the planner=E2=80=99s expectations. We do= n=E2=80=99t see how many distinct keys were estimated or how many entries t= he planner thought would fit in memory. This makes it very difficult to und= erstand whether Memoize was a good choice or not, or how to fix it when it = performs poorly. Right. Without taking a strong position on this particular patch, I think it's entirely reasonable, as a concept, to think of making Memoize work similarly to what other nodes already do. --=20 Robert Haas EDB: http://www.enterprisedb.com