Re: How to retain lesser paths at add_path()?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: How to retain lesser paths at add_path()?
Дата
Msg-id 1288421.1659294648@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: How to retain lesser paths at add_path()?  (Nils Dijk <me@thanod.nl>)
Ответы Re: How to retain lesser paths at add_path()?  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Nils Dijk <me@thanod.nl> writes:
> Attached you will find 3 patches that implement a way for extensions
> to introduce 'a figure of merit' by the means of path comparisons.

I took a brief look through this.  I quite like your idea of expressing
PathComparison merging as an OR of suitably-chosen values.  I do have
some minor criticisms of the patch, which potentially make for small
performance improvements so I've not bothered yet to try to measure
performance.

* I think you could do without PATH_COMPARISON_MASK.  Use of the enum
already implies that we only allow valid values of the enum, and given
that the inputs of path_comparison_combine are valid, so is the output
of the "|".  There's no need to expend cycles masking it, and if there
were it would be dubious whether the masking restores correctness.
What *is* needed, though, is a comment pointing out that the values of
PathComparison are chosen with malice aforethought to cause ORing of
them to give semantically-correct results.

* I'd also drop enum AddPathDecision and add_path_decision(),
and just let add_path() do what it must based on the PathComparison
result.  I don't think the extra layer of mapping adds anything,
and it's probably costing some cycles.

* Perhaps it's worth explicitly marking the new small functions
as "static inline"?  Probably modern compilers will do that without
being prompted, but we might as well be clear about what we want.

* Some more attention to comments is needed, eg the header comment
for compare_path_costs_fuzzily still refers to COSTS_DIFFERENT.
(However, on the whole I'm not sure s/COSTS_DIFFERENT/PATHS_DIFFERENT/
etc is an improvement.  Somebody looking at this code for the first
time would probably think the answer should always be that the two
paths are "different", because one would hope we're not generating
redundant identical paths.  What we want to say is that the paths'
figures of merit are different; but "PATH_FIGURES_OF_MERIT_DIFFERENT"
is way too verbose.  Unless somebody has got a good proposal for
a short name I'd lean to sticking with the COSTS_XXX names.)

            regards, tom lane



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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: pg_auth_members.grantor is bunk
Следующее
От: Andres Freund
Дата:
Сообщение: Re: ci: update to freebsd 13.1 / remove minor versions from image names