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 1u55Kn-00ByO5-Ds for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 16:09:57 +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 1u55Kl-000Fd3-Kg for pgsql-hackers@arkaria.postgresql.org; Wed, 16 Apr 2025 16:09:56 +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 1u55Kl-000Fcv-9R for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 16:09:56 +0000 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u55Kj-000Oas-31 for pgsql-hackers@lists.postgresql.org; Wed, 16 Apr 2025 16:09:55 +0000 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-2c2c754af3cso3467960fac.3 for ; Wed, 16 Apr 2025 09:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pganalyze.com; s=google; t=1744819793; x=1745424593; 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=fg7jKLH7YXkJYGmv2/WYnHb6VV0D0w15SBHamIsFHqE=; b=ZedwO2+9Bm1F59+zjrED1OL+HhlS21XJy4Q0oUfeQIuVr0AhEMAb5ZZh5P7JSwKguv ze1G0jiddDnQaKpFxvxYD5ILAbg1SBfM1nmyo4Wxa/Bm1CtUn2WRFyD0jZeHC9WTSUp7 dtFOgJIQ4pvvuJVa33Py7MOZBNRu7qyHFwZRuuXUgqGvqy5NSBABmTfIZG5boAc48oMo W+R9YqVTIO+beZ/GE7X2b+xacRqIorzqERB4VfbBiPZmaZKY6KCqdLSf2jlZgZeivDcd WHuu9Q4jAHaaTD1IjD+s8hMOaQSU2tyelp+04+JEdX3GoLdESYJ7i/TYWgEiYEmHkwgq n2uA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744819793; x=1745424593; 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=fg7jKLH7YXkJYGmv2/WYnHb6VV0D0w15SBHamIsFHqE=; b=MfqVZUB9dh6Y0s5+A/nrIu90MXLZwh9qDw54jFGNFYS3aU3EbWCCmiDiCIN59loURx 7KT4vXgeuObBPHVT69Y3NOVqk+Bo+c4kAQHROqUJUx2dy/81KafL6vhIdmOO+qSvMysU lI0K0TfS8JCEnX6y1E+dPgrcjsGRO01kPqMJuqyKZBzsWg1twTiU0OJmL7laASOuPInf 0Sj/rPX6HrxvPCMD6MzJ6FWqYgc43nI8DRyDlhehd402+SZdd/aFjX5P34AL6yknVEpO zWa4tPMtPcbCFXwxnkQGPq171o2Cb45j1+EzOBMqBrvRLrJplYZcVs4/SXcxI4FnkY6y gyJA== X-Forwarded-Encrypted: i=1; AJvYcCXwSiE2+jYbOdl/dDGzKtYmUTTVlMvAxe+3akX5s1GsNe1SBfMjSA77S2s+PtJdWO2X1PXiLcJE14HaVXIl@lists.postgresql.org X-Gm-Message-State: AOJu0Yzx3zRUPmqGORCzc2zHumRWtcA4PQc6MlYVFYBd1756IWgd6pnU 02ZtYUEU1/YPVqHsO4reP/hJJZpIZroVP/oJDfCnuRvrH2F7NFSYQWqIuu7QEmPicu8ms2DfNUw NVWb03rVCidE/s5vngJAJA/9DR1UqeF+xcN0rCA== X-Gm-Gg: ASbGnctofL+q05ScT3iJsQtQCh/6fv+7YV9SCXxr1aHlkd9Cki+WR2GaCjk0bDDhbVO FNwjyMiGvvQfgB/T18kQCftcO51CQf1CyqwUCUxSgfGKwuV9wvqUZa9dMuy/h/RqFk4bCUgAsRr uU9S2LFJneWtBGqLl0ikC7IGuBhEy+9p3VVemLigbmp8yHBwxxqoDZoIU= X-Google-Smtp-Source: AGHT+IH1gO4SEXpZm88PlYqijQOUL+7psR0lu/GLfHU+L8ff/ZTd1gyNp8CEI9J1tb8RZpmBGBnL7OFop8Vx0DRt5lc= X-Received: by 2002:a05:6871:820c:b0:2b8:e4b9:47a3 with SMTP id 586e51a60fabf-2d4d2b94a1dmr1463117fac.22.1744819792725; Wed, 16 Apr 2025 09:09:52 -0700 (PDT) MIME-Version: 1.0 References: <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> <580fe72c-85be-45a8-9e00-6b5417690557@tantorlabs.com> <3ea66a50-e4b0-4f20-ae0c-4d9cbaf81cfb@tantorlabs.com> In-Reply-To: From: Maciek Sakrejda Date: Wed, 16 Apr 2025 09:09:41 -0700 X-Gm-Features: ATxdqUF7OpfU5WqH9Rm_kw72wleeshVWcW2DRnDBLCv_mQqnx04kQ9DA7jO--I4 Message-ID: Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment To: David Rowley Cc: Robert Haas , Ilia Evdokimov , Tom Lane , Lukas Fittl , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov , Andrei Lepikhov 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 Tue, Apr 15, 2025 at 1:50=E2=80=AFPM David Rowley = wrote: > On Wed, 16 Apr 2025 at 04:25, Robert Haas wrote: > > On Mon, Apr 14, 2025 at 8:23=E2=80=AFPM David Rowley wrote: > > > "Estimates: capacity=3DN distinct keys=3DN lookups=3DN hit ratio=3DN.= N%" > > > > Is lookups=3DN here the estimated number of lookups i.e. what we think > > nloops will end up being? > > Yes. The estimate is the "calls" variable in cost_memoize_rescan(), > which is fairly critical in the hit ratio estimate calculation. > > Technically this is just the Nested Loop's outer_path->rows. There was > an argument earlier in the thread for putting this in along with the > other fields to make things easier to read. I did argue that it was > redundant due to the fact that the reader can look at the row estimate > for the outer side of the Nest Loop, but maybe it's small enough to go > in using the above format. This kind of thing is nice to have in the text format, but it's really nice to have when working with structured formats. Currently, to get a loops estimate for the inner node, I need to find the parent, find the outer node in the parent's children, and get that sibling's Plan Rows (I think). It'd be nice to make things like that easier. Thanks, Maciek