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 1vi7uA-00Fk4s-1P for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Jan 2026 09:20:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vi7u8-00HWFN-1x for pgsql-hackers@arkaria.postgresql.org; Tue, 20 Jan 2026 09:20:04 +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.96) (envelope-from ) id 1vi7u8-00HWF5-0W for pgsql-hackers@lists.postgresql.org; Tue, 20 Jan 2026 09:20:04 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vi7u4-001ORX-1u for pgsql-hackers@lists.postgresql.org; Tue, 20 Jan 2026 09:20:02 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-59b30275e69so6479323e87.1 for ; Tue, 20 Jan 2026 01:20:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1768900799; cv=none; d=google.com; s=arc-20240605; b=iptLH6cdDIagMMPcxRazewt0nFrZSvOBFQI7LLRzy9uHZ64T9p3KzR+7SsQONacKvw yeN05A+/eFFsvrRMla5VkrHec9FYfqvRJYiXv0yU2iALAezIH7ZEzx59VGdiUu9PSgKE G5EFv6AoGupXmJ5ql/smEmT/1891YDoQjqGjYvvI7CKZ46LU9EYSAQgYwQKb5ZlUXWEm qOBa/HuUYWfxQ1nALx7wgibW+r5NBdGPG6Xi5yAFZAznKhpSitQGKSMLAAObo6xTeu6f SIIBayKUcWed++Vg3oGC3FWntYuQ1+mXcDi8rXTnSb0CJIZwJDQ0yqQ0AGYRWmM4mAGj nFoA== 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=uRm0GqSJIqYQbsuFurgKVLluoa+lFmCnHlOFRrhZptY=; fh=Yn1reaKrW2GFajvp3uVwu9arOUrhpviMw9BaLCSnX7g=; b=ZlesgVWaHNPaeWS7jtkD1G+Z+DCCAlzbZVeFd3tN0Rm+h4caQH9H22uob9pVpVNGji fhJ19G0PhkM/tDLezLcD1ogqToWr6a2qEXFU+d+X8I6tU0+ncaSsyCSxdcfmBWU4d/JB 5fakYn3irWY1a0AOtdTnhKI/3kvsJtfkJr7m0qR3mCrQ6Rb5ptXzuKrvPNTJkTaeDy07 3owJp8m9L1o5GLfY9Nx06R3NDLZpJYw19L1+AjccGgZQpBqn7CCb+nZX8Tea98JX3ePU /2i9PS85kIGy2HrenS0lTCEoRDS/reBU1NerUtKwkuy9V5sUYvYVfcRSuRROa7H7xfRm kEEA==; 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=enterprisedb.com; s=google; t=1768900799; x=1769505599; 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=uRm0GqSJIqYQbsuFurgKVLluoa+lFmCnHlOFRrhZptY=; b=PJb9N9qL+DOTwgiNMLWb0YTgp2ILGSXyqK+qupw4yNhE+9LvgqE36HboXobazRmU9W TBs7cO+t5nfGzcHA08iJQX201TK+bMCPY7Yu2qvklstFdobZkc0glP28cEElXRtfCWTd TXr4pQBDe1f5LjF/Rv27jHibsDVaY+hLSymp2yMLC6ItO827Q10eCVPD1VsLf+oJS9Jw pcHJSGbcy+0yYM/uEroxtgb7oZXlZVdQ0L3S88Xq35RzkEtPp620ZXCRVRJMairzwELG TynWQLGRJkGOaHTzGkGB6R71jIb2vWXP4OJKXys98PsAZ3b5W69IrW/BOrY+7ktAMUgN PwqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768900799; x=1769505599; 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=uRm0GqSJIqYQbsuFurgKVLluoa+lFmCnHlOFRrhZptY=; b=NlAgYDUxUQ+1fXwfbwNDsHoj9hBg8moUZi2XsiCIdntaabJnaZjSURVEc6U8N5Icze 0CWol9cxw8G0Q0SJ9eog6j0LasLpc9foVdZEnPtkuWskvnlqUBCRXATcehYHiRh/WBpY wH6WwPOencv2G833j9grXukwcQOUnOPOFMjSFQObMoeMJJ9uQKLQLQblfKTXCraXFs9h xQfnteMkoAkYFDvkcqZCMuT+0//7EUCHv/nA7tnWQKbjdXEoE6+aT9J11NbAbkrH0kw4 PMQp3ZpUsI/iXsJgdFfqpIvK/9tPf0e7g26zJN5hf7JRXW19HLB8x5ZniQnk4S7I8fsA zpRQ== X-Forwarded-Encrypted: i=1; AJvYcCU3+AVNtdDDrSG611JBBoKMRvxKISS7UK8Qta6aDBsVF4Zk3gS+qiRcSYAOzMN44YDLStbxXpK+RR+wzMph@lists.postgresql.org X-Gm-Message-State: AOJu0YyOPWnSYvHrpysb7P25GjYL58FXaF2siiDeGcvpXInR5N57b3Ev r/+gsS1HBNFZOARYbtX78ZKttHfeWBnNWtPQMEMmLHY8IXshJYaGkwVYyOWdf3YX/DNF9UfKrgh SSx4DfdcjrT6RKK+s6AaSFuPKWm4lgsytFZOggj6y X-Gm-Gg: AZuq6aKFQ2DkaRHe475Ytvr2vb0ML32yxLNBZT6b3ayEHIXQZQsju7/+EDHIi1XyPE6 5PjLF5x/lurX8fQtxhfkV/7dS+w230MR7Cug4jPHrFA+tSqrxtA0xkfNTy316LGhw6BP16N7+zI JUYwW7xOamiiCcP5hbtSWkEv4f4pV1xKowapf7NEpTcl1jmncV28LLxQ9Gu3wHpCILjRqi2z7n0 KRG67Yoqh3da/IT9/r+jh3iF+dP+X/o4jXroOgU/96HsospeWaxMYpyXM4jHwPiqMy+NgPhwIzq 0rcuWJvmy2ajWXXZKoVe3iTWeG+MScgApxCkd+Jo71axhKaWiJVH4aIhUBIzZD1k5A== X-Received: by 2002:a05:6512:33ca:b0:59b:b0ca:67d9 with SMTP id 2adb3069b0e04-59bb0ca67eamr4565513e87.33.1768900799373; Tue, 20 Jan 2026 01:19:59 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jakub Wartak Date: Tue, 20 Jan 2026 10:19:48 +0100 X-Gm-Features: AZwV_QhYXWYd2Fhp75tEgnkEVa3DVB23z682nG_42wHMXvxsnBnCyTv2ByAiGIU Message-ID: Subject: Re: pg_plan_advice To: Robert Haas Cc: Lukas Fittl , Jacob Champion , Dian Fay , Matheus Alcantara , PostgreSQL Hackers 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, Jan 19, 2026 at 9:00=E2=80=AFPM Robert Haas = wrote: > > On Mon, Jan 19, 2026 at 5:53=E2=80=AFAM Jakub Wartak > wrote: > > a) v10-0001 - any example producing such a dummy subplan? (whatever > > I've tried I cannot come up with one) [..] > EXPLAIN SELECT * FROM random() UNION SELECT * FROM random() WHERE false; Oh well, that was easy, thanks! Now I see `RTI 3 (function, in-from-clause): / Subplan: setop_2 (dummy)` I don't have any further insights on v10-[124] other than mentioned earlier= . > > c) In v10-0004, maybe in pathnodes.h we could use typedef enum rathe= r than > > list of #defines? (see attached) > > I personally hate that style and I think Andres loves it. Whee! Oh, ok, nvm, but while two of You we are at this, vim or emacs ? ;) /me ducks & covers > > 4. Some raw perf numbers on non-assert builds (please ignore +/- 3% > > jumps), it just hurts > > in one scenario where oq2 drops like 9% of juice (quite expected, it= 's not > > an issue to be, just posting full results) > > > > tps oq1 oq2 oq3 oq4 > > master 41 14745 439 435 > > master+v10-000[1-4] 42 15055 439 432 > > master+v10full 41 14734 429 437 > > master+v10full+loaded 42 15014 442 438 > > master+v10full+loaded+advice 41 13481 424 439 > > > > (same but in percentages) > > %tps_to_master oq1 oq2 oq3 oq4 > > master 100 100 100 100 > > master+v10-000[1-4] 102 102 100 99 > > master+v10full 100 100 98 100 > > master+v10full+loaded 102 102 101 101 > > master+v10full+loaded+advice 100 91 97 101 > > I think these numbers look pretty good. I mean, there is obviously > room for improvement. We should look at where the CPU cycles are going > in the oq2 case and try to optimize. But even without that, it's not > terrible, IMHO. > > > So out of curiosity the oq2 on 1 CPU core behavior looks like below: > > - no advices --> ~1000 TPS > > - enabled pg_plan_advice.advice to lengthy, but unrelated thing and it > > gets ~890TPS > > I'm not sure exactly where the CPU cycles are going here, but one > known problem is that we have to re-parse the advice string for every > query. This thread discusses the challenges of creating some > infrastructure that would allow us to avoid that: > > http://postgr.es/m/f87504a6-9dfd-4467-89de-84232cb54f72@gmail.com > > Maybe I should start thinking about other ways to avoid that overhead, Meh... > because that thread doesn't seem to be progressing much, but maybe the > reparsing isn't even the main problem. > > - in both cases (empty and set) the bottleneck seems to in palloc0, but > > empty plan_advice: it's more like palloc0() <- newNode() <- > > create_index_path() > > <- build_index_paths() > > with plan_advice set: palloc0() <- newNode() <- create_nestloop_pat= h() .. > > I've also seen some palloc-related issues with the patch -- it has to > build some data structures and that does palloc stuff -- but there > shouldn't really be any difference in the code paths you show here. > That's just core code, which should be doing the same thing either way > if the advice is not relevant. Yeah, in both it looks like memory allocation and lots of newNode() called , quite expected. > > - so if anything people should not put something there blindly, but jus= t SET > > and RESET afterwards (unless we get pinning of SQL plan id to advices= ) as > > this might have cost in high-TPS scenarios. > > Yes, I think that's definitely a potential issue. I'd like the > overhead of this module to be as low as possible, but it's bound to > have at least some overhead, and people will have to decide whether > it's worth it. I think we should simply ignore, and maybe later just note the fact this is not free with a single sentence in some docs for 0005. I was just curious o= f the impact and this was measured using pure EXPLAIN (so without query execution= to measure impact of non-empty pg_plan_advice), I'm assuming that in properly managed systems execution part will always dominate the workload anyway and one should be using prepared statements anyway. -J.