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 1wX6hR-0033Zg-1T for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 00:21:42 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wX6hP-008cvG-0o for pgsql-hackers@arkaria.postgresql.org; Wed, 10 Jun 2026 00:21:39 +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 1wX6hO-008cv8-0z for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 00:21:38 +0000 Received: from fout-a2-smtp.messagingengine.com ([103.168.172.145]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wX6hK-00000002F0a-36AA for pgsql-hackers@lists.postgresql.org; Wed, 10 Jun 2026 00:21:37 +0000 Received: from phl-compute-03.internal (phl-compute-03.internal [10.202.2.43]) by mailfout.phl.internal (Postfix) with ESMTP id C35C8EC01A0; Tue, 9 Jun 2026 20:21:31 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Tue, 09 Jun 2026 20:21:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1781050891; x=1781137291; bh=ySkEimV/1a 7Z+rrWd39Dc8RiObDRJFOtgIePo/eRz+A=; b=Qv6xCDt40ZNw64sYNLQAF2QptW o+gA4Ry+oaxIdrsGVgNvIxpIFLjgZxFXFcVP/kqKbAiDU2dOGT+TGF93Giu9lSgX /rNLsolj/gxHg13ZOBMcBm54lkIysMgaQE2Aepy/R8KQQKw4opLWR3BE1F1yRMkW yPWgOlqfTqj8jay4/pFBlsI/PGyzBt3PvDHZDNxH+oEwycQsGShtKtlmLW+nxtfC 3hj7EfbAVgdcyNqieVxpqcFmEiNwJ/rN/uiQfDyeFH/6jPRkiKmdKioL3B1VdTP3 pLMaghlduMqMcTRdVRehr5+s3R4CWSeMlWUIPnn3TolclKXUD8NS4hS7yLgw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t= 1781050891; x=1781137291; bh=ySkEimV/1a7Z+rrWd39Dc8RiObDRJFOtgIe Po/eRz+A=; b=S+VqSZFy/4teGQa/DYQhHevKIcArptvP2vvJ1guezKtsJVMPLCP l5u6qHfpQ+i7IIfzAHapwa6RZ/ZKSKQuV0xbk1CRfCRFlBL7a17pK0ZSEsQ7Nmvi y1e486qZCeCxGU2bks7XCOKet5ravn3QpPJ0av0lJ0sVaXxjQciZLghJet7qFB9X 0eZ1OXE+cN68bRw0oQOhHnJhtswhpf+8/rwhYJjk5peu09LzNq+GoXEP64YmKg7W fRw5R9qAe7/x1bCtxM7ErlwXeRKbOav254nOuZPsi0YFohE/aL4eOEci051/SOQf SlHGaWTYOBPScthfGOByDgPnbCsljygTfSw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTE/mV2Pqv9Ng2KDr7jJ39J+qke8SunPNlvsXUxjtkal46Zte5pZPoUbgtZktmmxWw QA1b3usiHnaI77Y+nr1n9HN31rPG5PvLB8FgGTeE/1ytxpId6r/bQyfrHx/ABoQB9UKZ9w UerKXdFM7INHY5YCNFRNgIj9OmGtxu3cPTWqBWqUv6yJ826oAzFn848nyRFWpjU1pKq8K/ GjDOOhXMbbKhO3OAViw3GdAW2qeKhOEe+nv3KU1fc1ARf9EBPbQGwp/YYBOvHQK2PTN2wq 7urO2K2QNKzLfnCw2CXBPPZcF6ThevN3zwv3kL5JsvCatYDyvbdI5dg7sOWDavUP4cYSYw YzpV+anmAcZheIjr/bchLlRrPWIKm/+Y2GUTKVbJfCbZYXrqKN0X3M6thHq0Jkw79+ZhOZ dBA1yrbLD3D4Dnk1nfiBSiRbcGS+KqeTdwl/ojoRSgpKM5zLKr7S+/hXaGIkJLKq8+sMKh HvPIklZx4zJT7/6oZIjGrxJz13x2nBUu6DnrgpvJoi0RIufecAVWw2vOfGAlbOwIaunh1R oJ0O4J2It7GNOqjLt7D3pbFkfeC2ZrVJ91bTsRX+KE/9bawh1O+3xOeAc5OW0eIxulLKv3 3qZBVazDMAed7wVIN1orKRR5XNtGi7ZOLMsdkH8/5ZoheEG+LvvzeZEoDp1Q X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 9 Jun 2026 20:21:29 -0400 (EDT) Date: Wed, 10 Jun 2026 09:21:25 +0900 From: Michael Paquier To: Robert Haas Cc: Andrei Lepikhov , Tom Lane , Alexander Lakhin , Lukas Fittl , PostgreSQL Hackers Subject: Re: pg_plan_advice Message-ID: References: <3877210.1775272486@sss.pgh.pa.us> <386d8c06-0f96-40bb-b1b1-107db209c676@gmail.com> <2e7bdb5d-68ba-4c65-9931-a865ab6fc3d2@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="N1t2p3PnLwAOCwuY" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --N1t2p3PnLwAOCwuY Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Apr 06, 2026 at 10:01:52AM -0400, Robert Haas wrote: > On Mon, Apr 6, 2026 at 9:22=E2=80=AFAM Andrei Lepikhov wrote: >> It would be better to introduce such a code at the beginning of the >> development cycle, not right before the code freeze. At least we would >> discuss its design without rushing. > > Yes, the timing is not ideal. However, I posted the patch on October > 30th and committed the main patch on March 12th. I think that's a > reasonable length of time to wait for people to provide feedback. (Speaking with the pg_hint_plan kind-of-maintainer hat on.) The timing is fine IMO. In terms of integration with new APIs of upstream, there is really nothing one can do until we are at least in feature freeze. Trying to work around APIs that have been committed in the tree, which may be tuned after the initial commit, is just a loss of time. Things may get adjusted during beta, but the waves are much weaker to deal with. > During that time, the only person who provided information on how this > will interact with out-of-core extensions was Lukas Fittl, who came to > the conclusion that the pgs_mask infrastructure will be reusable by > pg_hint_plan and will result in that module being simpler and > involving less code duplication. Other extension authors could have > provided feedback during that time as well, but none did, even after I > posted to my blog to try to raise the visibility of this project. As > far as I can tell, most extension developers don't pay much attention > to core development until after we ship a beta. Had I waited until > July to commit, I think there's a chance that it would have simply > resulted in me getting whatever feedback I'm going to get next summer > rather than this summer. At least this way, the issues will hopefully > be fresh in my mind when the feedback arrives. I have an answer to this one, in the shape of the following commits in pg_hint_plan: https://github.com/ossc-db/pg_hint_plan/commit/e42246a82589001de2f08255d3b4= d984fb134d38 https://github.com/ossc-db/pg_hint_plan/commit/75b3d0142d2a8ea0e3d656e1c95e= a3fdd6e8f082 https://github.com/ossc-db/pg_hint_plan/commit/5d386d3ecb832d3ea205d1e42e30= 5cafefbefc76 The first commit is the most relevant one, and on a number basis I finish with that, where I have been able to basically remove *all* the historical hacks of the model in terms of plugs it added in the planner: 17 files changed, 1486 insertions(+), 3820 deletions(-) At the end, I am particularly happy with the way things are regarding the new join_path_setup and joinrel_setup hooks, that have removed most of the bloat. One thing that has caused me quite a bit of headache was parallel hints. At the end, I have followed Lukas suggestion to remove the old path regeneration logic that was based on an enforcement of the GUCs and switched to the PGS logic. This is coming with some breakages in the module, but these are actually super minor compared to the accumulation of weird historical behavior that we had in it: - When specifying only a JOIN hint (without leading), we now let the planner decide the inner/outer order depending on the cost it sees, not the order of the clauses. That can always be enforced with a Leading hint, which is the same thing as the JOIN_ORDER hint in pg_plan_advice. - Some slight changes in the way parallel hints are propagated to child relations, due to build_simple_rel_hook(). We cannot really avoid that, both behaviors are debatable, edge enough that I don't worry much in terms of plan instabilities after a major release. We have some degree of that for each major release, users care *a lot* about plan stability across minor releases, work around these after major upgrades. I strongly suspect that all these things are just going to be noise. The regression test suite has basically no changes. There are still gaps between pg_plan_advice and pg_hint_plan, and the maintenance of the latter is now muuuuuch easier (still need to maintain some versions for the stable branches). The end game for me would be to close the gap and merge both things together, then drop pg_hint_plan. I'll try to find some victi^D^D^D^D^D resources to do some of the leg work to do the gap here (not planning to do that myself), for some patches to-be-proposed in v20. We have row hints, parallel worker hints (aka RelOptInfo.rel_parallel_workers), memoize hints, SET hints that could be added to contrib/pg_plan_advice. There are also hints that negate scan behaviors. The negation hints are not that popular, I think, but that may worth considering. As of today on HEAD, 60%-ish of the remaining code relates to the custom hint string parsing and feeding into the various hint structures. 40%-ish of the code comes from the hooks and the internal routines used by the hooks, for something like 5k lines of code. This is a difference between night and day. (There may be more simplifications doable in the code, planning an extra round of checks during beta.) In short, thanks for the work you have done in the v19 release cycle in this area, Robert and others. -- Michael --N1t2p3PnLwAOCwuY Content-Type: application/pgp-signature; name=signature.asc -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmoorgUACgkQnvQgOdby QH0TuA/+PLL9/jB2nT16HSrg1rKhFzAukBiZv83zQs2RkwxogabEN03SVLPgYliG 2PanExmUnkvI1WX+K1VSxXO49q7lf9qGV40VCfBCbXqAmdEuTjyvq67p5VbiI48h LzPfyvhRdK//pWbognK4hz2iox0BeSWun9/I3pSUN58LWNU3I7ukZv1rjHzvwew3 zt7ViigUI06CR1C02rgopvIiC5emTn/ivTYv+GBZekNxwtpTVLCAwmvmENVkwtz2 1+QADUGeTe5UB69ApbIafTNODNqD1TBI77wjmn4yAWZv/NRLnjzLIfoV4H2ZFjF6 3bsOaN8QBZnUQ3ARL5Pte9AZiGpQwWxAnPYFMBzp+mLlqvqg3GzGRC7DkX4IDl4i gAnwKclKV4b0MpDCk1u8Qdb8pUN7i0jP34jDTje8m95KcGUsi8KAKDme2GLyq5rV JuToGJhokIxSaMotYjkHGxienmSJ7ka1KNzgD+mCFF3oVdbljaSCJZEl2Q0GLpnb 5UiVL+Z2eEX1MDII8Vo7m4xzMisOtJw4ZWuDWwbiznDfSYLXfDUe1phIwRKAJIop wOpLL0vrRZ20GqEVCLM1TRgg6qdbWiQLF3ceRkP2jvygrqNjOF+D2yqqNQzlGHV9 KL5kTFymuj34YJnUUwXzsEKiBulG6D5Qv/Ff8RkiJhaoXpk/c0U= =1N/4 -----END PGP SIGNATURE----- --N1t2p3PnLwAOCwuY--