Re: Rangejoin rebased

Поиск
Список
Период
Сортировка
От Jeff Davis
Тема Re: Rangejoin rebased
Дата
Msg-id CAMp0ubeu-0iJqVv=dAiCaHtTEwwuyq4-OSEUOECxnvZFq-HF=g@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Rangejoin rebased  (Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>)
Ответы Re: Rangejoin rebased
Список pgsql-hackers
On Fri, Jan 12, 2018 at 11:02 AM, Alexander Kuzmenkov
<a.kuzmenkov@postgrespro.ru> wrote:
> The sort order isn't right for the join, it seems. I remember having similar
> troubles with my full merge join implementation. I tried filtering
> unsuitable paths in try_mergejoin_path, but that was not quite enough. The
> planner tries to use only one sort direction to limit the number of path, so
> the path we need might not be there at all. This optimization was added in
> commit 834ddc62, see right_merge_direction(). Sadly, I have no idea how to
> solve this.

Interesting problem, thank you. My first reaction was to hack
right_merge_direction() to recognize the range opfamily in the ASC
direction as always potentially useful. But what's happening is that,
when the inputs are already forced to be sorted DESC, as in your
example, there is still no appropriate pathkey. So the problem is
reproducible with no ORDER BY clause at all.

My proposed fix is to make an internal opfamily identical to the
external one, such that it's not recognized as part of the same EC,
and the planner won't try to eliminate it. It loses out on potential
optimizations, but those are mostly theoretical since the btree
opclass ordering for ranges is not very interesting to a user.

I notice that window functions seem to handle these cases better,
maybe that approach would work for your full join patch? I haven't
investigated that yet.

     Regards,
           Jeff Davis


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

Предыдущее
От: Vladimír Houba ml.
Дата:
Сообщение: jdbc targetServerType=slave with readonly connection
Следующее
От: Aleksandr Parfenov
Дата:
Сообщение: Re: PostgreSQL crashes with SIGSEGV