Re: Poor query plan across OR operator

Поиск
Список
Период
Сортировка
От Kevin Grittner
Тема Re: Poor query plan across OR operator
Дата
Msg-id 4B5F049E020000250002EC4B@gw.wicourts.gov
обсуждение исходный текст
Ответ на Re: Poor query plan across OR operator  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-performance
Tom Lane <tgl@sss.pgh.pa.us> wrote:

> Actually, in the type of case Mark is showing, the estimates might
> be *more* accurate since the condition gets decomposed into
> separate per-table conditions.  I'm still dubious about how often
> it's a win though.
>
> There's another problem, which is that transforming to UNION isn't
> necessarily a safe transformation: it only works correctly if the
> query output columns are guaranteed unique.  Otherwise it might
> fold duplicates together that would have remained distinct in the
> original query.  If your query output columns include a primary
> key then the planner could be confident this was safe, but that
> reduces the scope of the transformation even further ...

FWIW, I've seen this optimization in other products.  I remember
being surprised sometimes that it wasn't used where I thought it
would be, and I had to explicitly transform the query to UNION to
get the performance benefit.  That was probably due to the sort of
constraints you mention on when it is truly equivalent.

Personally, I'd put this one in the "it would be nice if" category.
Does it merit a TODO list entry, perhaps?

-Kevin

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Poor query plan across OR operator
Следующее
От: Scott Carey
Дата:
Сообщение: Re: Inserting 8MB bytea: just 25% of disk perf used?