Re: Removing unneeded self joins

Поиск
Список
Период
Сортировка
От Thomas Munro
Тема Re: Removing unneeded self joins
Дата
Msg-id CAEepm=1TAUo5iJFRsX+=pHtTJFwHyGhD2cHuyF9Or95UiYmnbQ@mail.gmail.com
обсуждение исходный текст
Ответ на Removing unneeded self joins  (Alexander Kuzmenkov <a.kuzmenkov@postgrespro.ru>)
Ответы Re: Removing unneeded self joins  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
On Thu, May 17, 2018 at 3:43 AM, Alexander Kuzmenkov
<a.kuzmenkov@postgrespro.ru> wrote:
> There is a join optimization we don't do -- removing inner join of a table
> with itself on a unique column. Such joins are generated by various ORMs, so
> from time to time our customers ask us to look into this. Most recently, it
> was discussed on the list in relation to an article comparing the
> optimizations that some DBMS make [1].
>
> ...
>
> I'd be glad to hear your thoughts on this.

+1

Some thoughts:

There might be some interesting corner cases involving self-joins in
UPDATE/DELETE statements, and also FOR UPDATE etc.  Those can result
in some surprising results in a self-join (one side is subject to EPQ
and the other isn't) which I think might be changed by your patch
(though I didn't try it or read the patch very closely).

IIUC in DB2 (the clear winner at join elimination in the article you
mentioned), you get these sorts of things by default (optimisation
level 5 includes it), but not if you SET CURRENT QUERY OPTIMIZATION =
3 as many articles recommend for OLTP work.  I think it's interesting
that they provide that knob rather than something automatic, and
interesting that there is one linear knob to classify your workload
rather than N knobs for N optimisations.

-- 
Thomas Munro
http://www.enterprisedb.com


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

Предыдущее
От: Alexander Kuzmenkov
Дата:
Сообщение: Re: Removing unneeded self joins
Следующее
От: David Rowley
Дата:
Сообщение: Re: NaNs in numeric_power (was Re: Postgres 11 release notes)