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.96) (envelope-from ) id 1w3GfD-0013ua-0S for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 16:56:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w3GeC-001DcD-0m for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Mar 2026 16:55:00 +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.96) (envelope-from ) id 1w3GeB-001Dc5-30 for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 16:55:00 +0000 Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w3Ge9-000000002J1-1vef for pgsql-hackers@lists.postgresql.org; Thu, 19 Mar 2026 16:55:00 +0000 Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-b979d16dd0cso118846366b.1 for ; Thu, 19 Mar 2026 09:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773939297; cv=none; d=google.com; s=arc-20240605; b=dLH2SuV+eGhl5uPDqHC9A9uAwkY3cWoTbDoppTyYfK2f7N5H47Gy6MBYZLLGubFiWP erRyfzts1QBhktHQuL4ejsL76xvdZHd24Wywgb2K6t06zivXAnhmGaDu9rjDS5Q+bzsr NLaIypvUsngcsVhiDn+iwOtQ9hpqYFInZXeA15ypJnPqO4IHrklc6RCTkH50YktLDSvh vWQlPT+JcZfikZu0RJhaWqKrwl8tt5nG4oQDiIca0snuhdSSz+tSu6+7AfigmZKdnm0m 16bbrBxsHwf7VrHGnm0ujvuV7sja5cu+DVlI2P6PQUN5aNpyuuEA9/iQPQqyAGVJHNfa Sfmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=oTlZn0xfROc2TeaZJ/dLpwrCTN4PpSC9Rb4Wd7VCDqo=; fh=vP8CEIypd4T5lsI+k+Ckg4oW9uFn19gkm5H2Qb41djI=; b=QZq3lKjJQQSruO3yFg0sKiKBLlg3kVsk/JEf1Evohkw7SOwbyfbFnbY2//KWdcfZCT vbsQzvT3RAOBLp8FCjp91VzNIW6wgrNhrFohRf6PyJrezz1n4W41iLI0dp3n1DBWL1th qntAsrV2F/mKBgVMd+NcrALZtdT7kU4iwcUrLIleS9LH0tSJw0fkHjjAz2P9wNju+eui CTHGpN9N8J1RbW144d7NVSdnDBcfkkOsz1mm+x/ZAXCyHDhpk3o2Z+n9UMUr3bVpKsGn MAlSB6t8Z/XE0Rabset9DZP8crhJwbh3ZjMzN3klPchZYZEsw4BweOMtsUL8REfkXvrA laog==; darn=lists.postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773939297; x=1774544097; 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=oTlZn0xfROc2TeaZJ/dLpwrCTN4PpSC9Rb4Wd7VCDqo=; b=k+A5jOmlm/xruXE70CfL51MqQ56JNHO3HiIfO/9zL/DLL9Vt1WzxSZpCwKU6yRnNzk UdbesTSLCCefzKji0iJpsdZRaDVM4nyqKeiYzpmGvZuofVNG7w85F7Ho62mHyqIuoQyz 1gzTKnQK2FtVb7LF3Quy1flYNlf/o8Um2svmovZK23M9xEiqRLwof2c3e8Qj5KDAyxra kJaClL/JOssSrXxyR4M0g7pwZgL8N+hqM/eSoS0QLHaQ1sR+idoAZT/sj1DGYvymSMU9 y+Yc0NGTGNkIDxCypifyJF1qSLMJvWpg0ohPmI9sYEHbvrLutEGq+vF593zfvuoRuox/ d5kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773939297; x=1774544097; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=oTlZn0xfROc2TeaZJ/dLpwrCTN4PpSC9Rb4Wd7VCDqo=; b=R72jC2gSn+C79edS41C3ZzCdUH6jktGpmegHtcK8UPaJdO8iU0C0TAdX97/Dek8d+l LCdN8YUoHUMwhS7RP5S9T9WPP/V5iiawpiqRLDQ1XOMLilcUaWkdtcC35tZPKmAAehLJ TPgFGUUzM9PIhD7EPqUv9mhgk4gpDeOLuUVuwkFaHfc6KoIfS3j9ODfMYY3CN0moZZYy KSEOZjFzyXewpW5VPGMbguk+wgdo6s3unktESET/WXtsstlPyh9x0fRM1A6Dj3ZAc49r ut8ZGdDZJl0kvmtI4nbejMU9f1l1f04Rqs6zdi9uMCGkcdLHNgUL+6shehZoDFQhuAIf dSZw== X-Gm-Message-State: AOJu0Yzrg4mk6LJRsPm3a8amYD1a5FNXDPYwbPI3nOMTboTUEMOnOt/c bEm8fhAjEsSA+YNhbThCo7E1fLVBTn5VXTfB0nGqvhFfbX/Qtmh6hHEiG7zI+sEw+71LdkKI6eP 6AnRLUoUBdYOfx65wIH8QsAOtX65SsQy/XA== X-Gm-Gg: ATEYQzwQbBTaILYGc7AjwX4IUAVxZPQXZcNib5c3026L8E9X7IW94F6Ui6GOh85oJDH Wn0Iv+VkgZMl/xq2aHmPY2af6vnXPV9HyfZWijjS2R5eoEZt7/z3FXuiEkuaUtTY0s/dKh/bqQV Zn440Kkuhr/s+N7OyGRirhHNrwaUKFiBV577Wz/XTnPU8okGB2//UAFpoAee3DErBHk27d8Z1jN DxVzP2s+5pqvW1W8AbDmbqfySsy2QMhKNGPBWITQsOBhl9Xjqbpx4OdMJtYhp1uI3NlLhjVimgv pm23hGZuhthmyHDf+qTmFtTW4hvGkvDpBuM7q/0= X-Received: by 2002:a17:907:c9aa:b0:b93:81e7:8458 with SMTP id a640c23a62f3a-b982f0bab34mr3996266b.2.1773939296183; Thu, 19 Mar 2026 09:54:56 -0700 (PDT) MIME-Version: 1.0 References: <1136161.1769654478@sss.pgh.pa.us> In-Reply-To: From: Robert Haas Date: Thu, 19 Mar 2026 12:54:43 -0400 X-Gm-Features: AaiRm51sP72h__hRRI0mB2ek_nQHBBZt-LuOP2k21ysEWYSEETP9EIZLsF1Xugg Message-ID: Subject: Re: pg_plan_advice To: Lukas Fittl Cc: PostgreSQL Hackers , Tom Lane 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 Wed, Mar 18, 2026 at 3:00=E2=80=AFPM Lukas Fittl wrote= : > I think we have similar problems elsewhere in Postgres where a large > user input causes an even larger log output - e.g. a case I'm familiar > with are complicated queries with long IN list inputs and their > associated EXPLAIN plans being logged by auto_explain - I recently had > a case where someone reported an OOM due to auto_explain trying to log > a > 100 MB sized query plan. > > I think its actually less a problem with plan advice, since presumably > we won't have ORMs generating plan advice, and even if we do it'd be > per-table - so I think its unlikely a genuine use case would use 1000s > of advice tags. > > That said, I also don't think super long long messages are actually > helpful. I do wonder if we should have a more coarse GUC that limits > DETAIL lines of any kind to a maximum length (e.g. 100 kB) across the > board instead of special casing every emitter. I think it would be difficult for generic code to do something sensible when the message is really long. I mean, it could just cut it off after N lines, but then you have no idea how much more there would have been, and you probably want to tell the user something about that. You could add a completely generic message to the end like "plus 10525 more lines of output that were truncated for display," but that's pretty unsatisfying. If you want to show something contextually appropriate, the implementation needs to be separate for each case even if the limit is common. Anyway, the question here is not about such a generic mechanism, but about whether somebody wants to argue for sticking a limit of 100 on feedback messages on the theory that log spam is bad, or whether it's fine as-is either because (a) the likelihood of a significant number of people hitting that limit is thought to be too low to worry about or (b) the likelihood of someone wanting all of those messages (e.g. for machine-parsing) is thought to be high enough that a limit is actually worse than no limit. I do not really have a horse in the race, so if nobody else has a strong opinion, I'm going to leave it alone for now and consider changing it if a strong opinion materializes later. > 1) What if we return the utilized advice string as a separate DefElem > with a list of strings, and then the feedback just has to reference an > index into that list? (though I suppose that doesn't actually save > memory, now that I think that through -- unless we assume the caller > already has the advice string, but I don't think we can rely on that) I think that if we're using Integer nodes, it's just never going to be very economical. We could use an IntList, which I believe would be better, but there are a few complications that make me not like this idea very much. One, what the feedback is actually about is a reconstruction of a particular advice item into string form, not the original string, e.g. if you input SEQ_SCAN(foo bar), the feedback will be on SEQ_SCAN(foo) and SEQ_SCAN(bar). Two, even if you ignore that, this would leave consumers of the data with the problem of finding the end of the advice item unless you stored both starting and ending indexes, which would have its own costs. > 2) We could consider having separate DefElems for the different flag > types (i.e. "feedback_failed", "feedback_match_full", etc), and then a > list of strings attached to each - that'd save the nested DefElem and > the Integer node But it would also very often duplicate a bunch of the strings, which seems likely to work out to a loss more often than not. You could avoid that by have a list of strings per unique flag combination, but that would be extra work to compute and I think it would be less convenient for consumers. One user-visible consequence would be that the advice feedback in EXPLAIN output would have much less to do with the original order of the advice string. --=20 Robert Haas EDB: http://www.enterprisedb.com