Re: pg_plan_advice

Поиск
Список
Период
Сортировка
От Lukas Fittl
Тема Re: pg_plan_advice
Дата
Msg-id CAP53PkyEr3W0oLnT8aeq+Za6Rm04vCO+YzAB+uf=N9T8WqWmfA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: pg_plan_advice  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
On Thu, Jan 8, 2026 at 11:37 AM Robert Haas <robertmhaas@gmail.com> wrote:
> Ideally, if you say "hey, I want to use parallel query here," you
> would get the best plan that the planner knows how to construct that
> happens to use parallelism. #2 sounds to me like you weren't really
> getting that, because you were making parallelism on cost rather than
> disabling non-parallel paths. #3 also sounds that way, because you
> asked for parallelism and didn't get it. So I would tend to view those
> changes as improvements.

Agreed from my perspective.

> The others are a little trickier. I don't think I quite understand
> what this patch changed with respect to #4. I'm guessing that maybe
> what's happening here is that this isn't really due to anything in the
> patch set, but is rather due to relying on pgs_mask rather than
> copy-pasting lots of code, which maybe incidentally removed the
> ability to tweak something that pg_hint_plan was previously tweaking.
> Maybe you want to think about writing a patch to go with 0004 that
> addresses that gap specifically?

Yeah, I don't think this needs to be reviewed in detail here now, but
I do think there is a potential to improve worker count overrides in
core code. I agree this can be done as a follow-up to 0004 - and I
don't have a good sense yet for how infrastructure for this could look
like.

pg_hint_plan has some existing logic to copy parallel worker counts
into other paths (e.g. for joins), and I kept that for now in that
draft patch [0] to reduce further test output differences.

> I'm actually kind of surprised that you didn't run into a similar
> problem with the Rows() hint, for which 0004 also doesn't provide
> infrastructure. If there's no problem, cool, but if there's a problem
> there you haven't detected yet, maybe we should try to plug that gap,
> too.

Yeah, 0004 doesn't provide infrastructure for that directly. However,
it does add joinrel_setup_hook which enables modifying joinrel->rows
at the right time without copying core code. Previously pg_hint_plan
modified the row estimates for joins through copied core code [1], but
0004 lets it affect join rels through the new hook [2].

> I don't quite know what to say about #1. If your theory about it being
> due to the zero costs is correct, that's another example of the
> current implementation not really being able to achieve the ideal
> behavior, and the patch making it better. If there's something else
> going on there, then I don't know.

Yeah, I don't think we need to worry about this in the context of
applying 0004, and its something that Michael or other pg_hint_plan
maintainers can assess when updating it.

Its worth noting for clarity, whilst 0004 requires extensions that
modify certain GUCs during the planning process to instead use the PGS
mask, max_parallel_workers_per_gather is not one of these GUCs. I was
driven to also do the parallel hint changes because I wanted to prove
that pg_hint_plan can now function without any copying of core code,
but technically all the parallel regression test changes can be
avoided when keeping the prior zero parallel_*_cost mechanism +
modifying max_parallel_workers_per_gather during planning as before,
whilst still updating the scan/join hints to use the PGS mask logic.

Thanks,
Lukas

[0]: https://github.com/lfittl/pg_hint_plan/blob/postgres-19-with-plan-generation-strategies/pg_hint_plan.c#L4602
[1]: https://github.com/ossc-db/pg_hint_plan/blob/master/make_join_rel.c#L126
[2]: https://github.com/lfittl/pg_hint_plan/blob/postgres-19-with-plan-generation-strategies/pg_hint_plan.c#L4372

--
Lukas Fittl



В списке pgsql-hackers по дате отправления: