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 1tx0eZ-001pnC-J6 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Mar 2025 09:32:59 +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 1tx0eY-001NSn-C5 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Mar 2025 09:32:58 +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 1tx0eY-001NSe-2j for pgsql-hackers@lists.postgresql.org; Tue, 25 Mar 2025 09:32:58 +0000 Received: from mail-wr1-x42e.google.com ([2a00:1450:4864:20::42e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tx0eW-00116g-1x for pgsql-hackers@lists.postgresql.org; Tue, 25 Mar 2025 09:32:57 +0000 Received: by mail-wr1-x42e.google.com with SMTP id ffacd0b85a97d-399676b7c41so2844961f8f.3 for ; Tue, 25 Mar 2025 02:32:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1742895174; x=1743499974; darn=lists.postgresql.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=azJx/QKLhnOTWYQMox/Kj25Dz/1+ZyI8hAI2tV9rkDQ=; b=Ho+gWmi8edaSEgeAM92yB3XBMMxLYiLZqfb/y1Kn4e8CkRvTzDyr6PxU4/nQImVDXM 6yclQl6UX21tbu1EyO0yi+mC7krab8UWeu6IICdAx3r3M85b1BcyrbQ+PwPNg1xmrYwC 0g2tzRfxZ0i7+H7DLDtiPR4+3xO00QD14O8lYrV2j/g3HwoIc2yDaZVDOmNRsAS+Cztc 7KkuGvnDPZTGIegXdRXMIbYzQsZBroaTjBQpJOQnj4fxSvE2CH8HJsR0tWYqvGQovjMP VM+ARlhMmPF3doRn8ufBVL4ULRcNpsCjUwRVWpd2k2dN9YyQYRlPm+o+TfAxV8SGdpYF OF8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1742895174; x=1743499974; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=azJx/QKLhnOTWYQMox/Kj25Dz/1+ZyI8hAI2tV9rkDQ=; b=s9KOn10gb0gB1ommzDU3TBLiMLmH8aK8wM2ZaGBNet0R4tHWLMyCOoUc4RmCriuqN1 KGpGyxIh4/LPDEmyXABpVNiu+Fu/Sc642d7AIIiNOjErPxx3kGhLd5EusRrFEQOobqRs fVHnWzhpSiOfG00dLlt9TAoFa1m89fMMoCRM1XJiNdAW0uyjqfkDZ/JoPMFk7CsxkZwQ Ym7OWFSYhz4olmrNhWBoodbNZ65XzCALJ73fdbNwqGZx9GFIFOWNJmzvsuMaXEi24HhS jSehqL4Tz1UDTBvvQs3Xdum4pX89KGkvg9fonqY1RxdbPyyRFRVGVWCj9+GoI/O6dJbp wumQ== X-Forwarded-Encrypted: i=1; AJvYcCX6vzegdHeUsBWj/nF2WowPqTrJGKDJ5LeHC+ClPTcalBBwQ1CPUEY8f2zXSM15tpysLRBChdSPnVSUWiys@lists.postgresql.org X-Gm-Message-State: AOJu0YztSQgY5xVMaeu8AInq1F7Mj4KAe1b5iqcQE4plS5atkrxV3+t5 tP5RkIGHzyTGduRYYyhu8G6ihHxlcuMBPxjBrcvPQWpp3Vl7d+t5 X-Gm-Gg: ASbGncsF2qlzxKHhf3E4ZO90IN9hdcyyjDG9QTl83RBYOiIAxgpJJ2co/6h84u56Y/Z VI5IEp68S+CJb3qaOt75gFEi/qESlxwkeu3tU494l5LiIVy4AE7CvQsSFCD0g9e/2DLCc3KSXRp y0GovBhSlBgz15IYjdwn1kk+VBwBZ3NAdkF0RomYoJy6rP+P43G5t6S44f5RLUUSDm65BP3GGRw bnrbojWBKreNd0ZGhgiOhqadj5mWTMdTD9PSThi7VORjjeDptgezaPnjE7Rz0+7KfBI/wOwdIqm m/9JDEcGOYakWVX7ACZoqy1DZGdLMo0QlS/pCYxkDq/iTZfLASBHamX/T8aihkJs7apso3Szdr4 FFeWd4KORJHj0xw== X-Google-Smtp-Source: AGHT+IH1ma5Rov56V6ZePxBE23u4kEMcwwhQbBybuipSVmHcx1F8oeBbTBqd0k87wtvyX9YilhOGbQ== X-Received: by 2002:a05:6000:1faf:b0:391:2f2f:836 with SMTP id ffacd0b85a97d-3997f8fa7f6mr12949104f8f.17.1742895173775; Tue, 25 Mar 2025 02:32:53 -0700 (PDT) Received: from [192.168.0.89] (84.123.232.230.dyn.user.ono.com. [84.123.232.230]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43d43f556afsm194429625e9.19.2025.03.25.02.32.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 25 Mar 2025 02:32:53 -0700 (PDT) Message-ID: Date: Tue, 25 Mar 2025 10:32:52 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment To: Tom Lane , Lukas Fittl Cc: David Rowley , Ilia Evdokimov , Daniel Gustafsson , PostgreSQL Hackers , Nikolay Samokhvalov 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> Content-Language: en-AU From: Andrei Lepikhov In-Reply-To: <1164845.1742856354@sss.pgh.pa.us> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 3/24/25 23:45, Tom Lane wrote: > Lukas Fittl writes: >> 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. > 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 prefer not to see these numbers in the default EXPLAIN output, not only because they can fluctuate but mainly because I like to view the basic query structure without additional details. As I mentioned earlier, most of the information we typically need to explore query plans stays in path nodes and does not transfer to the Plan node. I believe this should stay as is, as we deal with numerous cases and a vast amount of data. It would be beneficial to expose extra data in an external extension. By implementing a `create_plan` hook and an extensible list node in both Path and Plan structures, we could provide a machinery for writing an extension that can expose any planning-stage information in EXPLAIN on demand. This could encourage developers to create a "pg_extended_explain" extension, which would address most user needs without requiring additional changes to the core system. -- regards, Andrei Lepikhov