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 1txWZU-00Ag0v-5k for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Mar 2025 19:37: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 1txWZS-009CFA-Qr for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Mar 2025 19:37:50 +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 1txWZS-009CF0-Dt for pgsql-hackers@lists.postgresql.org; Wed, 26 Mar 2025 19:37:50 +0000 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1txWZP-001NDW-2W for pgsql-hackers@lists.postgresql.org; Wed, 26 Mar 2025 19:37:50 +0000 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-ac2dfdf3c38so31812366b.3 for ; Wed, 26 Mar 2025 12:37:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1743017867; x=1743622667; 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=RrkS8ekCy/XL9QD9zoyCR1z4ZzBTDf6KhUMNpuw6d1A=; b=VeTzfSzjMW0LJxJLy+/YzEgLwCvo9ntf8YdXHgBqQ7ck0LsDQiWiFUROP/v7t2myOE Bq0xTwtGdSYhN4iSNSOdFbxL23Io5Vaq9DTEwkQiwuEZbP24IFppWYX1c8AjR3uiGH4K p3z2si5raMYUDvLbnfh/9hiYWPHDBztsG37TZW3sIWgTKzMOSXP+giJz4w/XE25ArQ+D iL9d8jkuzpgZPjmQYMOmeIMaJHMp9KZUqzj8Gg/CyG2Pvews4c2v1Y6yU5afTrFTr7Hm rhsuC3HRSeZFlsZ+6epLt0SLYcgtwyig7eVBkr3N0Oe2/sU961/xT+UPScmDC/989nHX qorg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1743017867; x=1743622667; 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=RrkS8ekCy/XL9QD9zoyCR1z4ZzBTDf6KhUMNpuw6d1A=; b=ekpotFs27JngCpyNKm8B+JNohq0KzOfRg4ybj/pb556Q6xQliu96lolBbrqBmw/WTU 7WB/5GIb66LVjbA6/3lOeu8mp0ToblrwRrPxyoJH7Hq7SK2Dq1lfjhQyYxhqoLBxgcPN LC8jv/KbHPMkm69WLTYLC0/ECjjJyJBSyCcIgCygF8yORj7e+ScLhhtbyc4TsMtJqelS PiM3dV5tkSKbbo0LM6FYwwLhNrOOU6gLbb4EIsksRQot1VGMgKgVbtENF0N1+yhEEZDc oCXrqrsEklcSP6mNMpiJydloZAF1Z5e2r9qNr2McTaEsPsh05XE1LkjkABeuPEiHGx9Y Vbqw== X-Forwarded-Encrypted: i=1; AJvYcCWWbRPw+zwCQaBmASaTaNWjPJpKfP7Pel2XjCqlvrYj9Z2wd8S7EX0Y7moYayGjwN3hHtdUeEUyuJ0GiLk/@lists.postgresql.org X-Gm-Message-State: AOJu0YwJGMN/ySIBhog31nM76oqdaw2YLJQFnxxIkgUofVGu9ddllWAO 5Te7vONOD5V6cU4P6qkcV2uG2BHDGeubciUJUGXPgKSfz97wgZS4L3PmPyo9CJe9IFbPzzbpY6T ev/YJt6sWTl+98ETSdtn9iHo9JCI= X-Gm-Gg: ASbGncvmqFJ2lN97NPmN8cktgPCFrCBRNu3iQ9JpfvQ/Kqt8knMW9u5fBEkhlUx5aOD h0aKAJnyA8YeF1IvbmR/JVNXPOOBJhzAHdiVhOmZKo4OvSKFlv+px19qkDM+2yr6SxsNgvcLMTJ fbfolqbag3oti+W+ODX6kmKDirPA== X-Google-Smtp-Source: AGHT+IHVzoiVPxKdF8c59sUDamnP533pZhZd24wmzltIuDfCLzq3JA1wVVrHM/Ee4sFHIukLqFtJxpuh1YCRV6dRW/w= X-Received: by 2002:a17:906:dc8b:b0:ac4:76e:cdc1 with SMTP id a640c23a62f3a-ac6faea8cf4mr59507166b.21.1743017866698; Wed, 26 Mar 2025 12:37:46 -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> In-Reply-To: <1164845.1742856354@sss.pgh.pa.us> From: Robert Haas Date: Wed, 26 Mar 2025 15:37:34 -0400 X-Gm-Features: AQ5f1Jo6tCr0VO5eDinwaiPh0i9BjeNeNl-eUeHAcfBZPP7fg_kwAc0uLMrOTzM Message-ID: Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment To: Tom Lane Cc: Lukas Fittl , David Rowley , Andrei Lepikhov , Ilia Evdokimov , 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 Mon, Mar 24, 2025 at 6:46=E2=80=AFPM Tom Lane wrote: > As I said, I'm not necessarily averse to showing these numbers > somehow. But I don't think they belong in the default output, > and I'm not even convinced that VERBOSE is the right place. > pg_overexplain seems like it could be an ideal home for this > sort of detail. I think we're going to be sad if we start shunting things that non-developers need into pg_overexplain. On the one hand, PostgreSQL consultants will be annoyed because they'll have to get a contrib module installed in order to be able to do their jobs, and I don't think that should be a requirement. On the other hand, PostgreSQL developers will also be annoyed because once the consultants start using it they'll complain when we change things, and I think we want to have the freedom to change things in pg_overexplain. For that reason, I think that if we choose to display anything here, it should either be displayed all the time or gated by some in-core option such as VERBOSE. I do acknowledge the argument that we don't show details of how costs are derived in other cases. While I think that point has some validity, the flip side is that I spend a fairly significant amount of time attempting to reverse-engineer what the planner did from the EXPLAIN output, and I find that pretty unenjoyable. The recent change to show two decimal places on row-count estimation is one that comes up a heck of a lot, and several people have thanked me for getting that patch committed because that problem affected them, too. But it's surely not the only example of a case where it's hard to determine what happened in the planner from what shows up in EXPLAIN output, and I think that trying to find ways to improve on that situation is worthwhile. I also don't think that we should be too concerned about bloating the EXPLAIN output in the context of a patch that only affects Memoize. Memoize nodes are not incredibly common in the query plans that I see, so even if we added another line or three to the output for each one, I don't think that would create major problems. On the other hand, maybe there's an argument that what this patch touches is only the tip of the iceberg, and that we're eventually going to want the same kinds of things for Nested Loop and Hash Joins and Merge Joins, and maybe even more detail that can be displayed in say 3 lines. In that case, there's a double concern. On the one hand, that really would make the output a whole lot more verbose, and on the other hand, it might generate a fair amount of work to maintain it across future planner changes. I can see deciding to reject changes of that sort on the grounds that we're not prepared to maintain it, or deciding to gate it behind a new option on the grounds that it is so verbose that even people who say EXPLAIN VERBOSE are going to be sad if they get all that crap by default. I'm not saying that we SHOULD make those decisions -- I think exposing more detail here could be pretty useful to people trying to solve query plan problems, including me, so I hope we don't just kick that idea straight to the curb without due thought -- but I would understand them. The part I'm least sure about with respect to the proposed patch is the actual stuff being displayed. I don't have the experience to know whether it's useful for tracking down issues. If it's not, then I agree we shouldn't display it. If it is, then I'm tentatively in favor of showing it in standard EXPLAIN, possibly only with VERBOSE, with the caveats from the previous paragraph: if more-common node types are also going to have a bunch of stuff like this, then we need to think more carefully. If Memoize is exceptional in needing additional information displayed, then I think it's fine. -- Robert Haas EDB: http://www.enterprisedb.com