Re: pg_plan_advice: add NO_ scan and join method tags

From: Florin Irion <irionr(at)gmail(dot)com>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: shihao zhong <zhong950419(at)gmail(dot)com>, Neil Chen <carpenter(dot)nail(dot)cz(at)gmail(dot)com>, song yanli <songyanlili(at)outlook(dot)com>, "Jonathan Gonzalez V(dot)" <jonathan(dot)abdiel(at)gmail(dot)com>, "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: pg_plan_advice: add NO_ scan and join method tags
Date: 2026-12-01 08:41:50
Message-ID: CA+HEvJDr_H-zf7_xnFe+6d0U_iWSFVwC3=UMvZ1J=+_tU3+zLA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Robert, thank you for the review!

Il giorno ven 20 nov 2026 alle ore 21:15 Robert Haas <robertmhaas(at)gmail(dot)com>
ha scritto:
>
> - I know that I was the one who proposed e.g. NO_NESTED_LOOP as well
> as NO_NESTED_LOOP{_PLAIN/_MATERIALIZE/_MEMOIZE), but as I reflect on
> that recommendation, I wonder if we should be adding positive versions
> i.e. NESTED_LOOP(x) and MERGE_JOIN(x) that allow all the versions of
> that thing at the same time. Or maybe this should be two commits in
> one order or the other. It just seems a little odd to be able to say
> NESTED_LOOP_MATERIALIZE() and NO_NESTED_LOOP_MATERIALIZE() and
> NO_NESTED_LOOP() but not NESTED_LOOP(). Or we could go the other way
> and only allow the full version: NESTED_LOOP_PLAN() and
> NO_NESTED_LOOP_PLAIN() but not the shorter versions. But right now I
> feel like it's not as consistent as I would like.

I think it is better to keep the NO_ forms for a whole family, and add
the positive forms NESTED_LOOP(x) and MERGE_JOIN(x) in a
second commit. IMO a single tag that covers a whole family is useful
on both sides. So I'd prefer to add the positive side.

>
> - Bare blocks are not PostgreSQL style i.e. don't do this:
>
> + /* Handle NO_ join method advice. */
> + {
>

Will fix.

> - I think the documentation and the commit messages need some
> word-smithing. The "negative counterpart" language is problematic,
> because the behavior is not exactly opposite. I would suggest
> something like this: Negative join method advice specifies a
> relation, or set of relations, that should appear on the inner side of
> a join, but which should not use the named join method. For example,
> NO_HASH_JOIN(a) means that a should appear on the inner side of some
> join that is not a hash join. I would encourage keeping the
> documentation for these negative tags briefer than for the
> corresponding positive tags, to avoid tedious duplication.

Agreed, thank you for the wording suggestion. I will reword the
docs in this way, keep the negative sections shorter, and also fix
the commit message.
> - Is there a reason for the no_scan and no_join tests to be separate
> from scan.sql and join.sql?

No reason. I will merge no_scan.sql into scan.sql and
no_join.sql into join_strategy.sql.

I will send v6 with 2-4 fixed, and with the commit for 1, if you agree.

Cheers,
Florin

--
Florin Irion
https://www.enterprisedb.com

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zhijie Hou 2026-12-01 09:06:38 Re: Add a hook for handling logical decoding messages on subscribers.
Previous Message Cagri Biroglu 2026-12-01 08:37:55 Re: Per-table resync for logical replication subscriptions