Re: Tricking the optimizer

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Tricking the optimizer
Дата
Msg-id 28215.1524059471@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Tricking the optimizer  (Vitaliy Garnashevich <vgarnashevich@gmail.com>)
Ответы Re: Tricking the optimizer  (Vitaliy Garnashevich <vgarnashevich@gmail.com>)
Список pgsql-general
Vitaliy Garnashevich <vgarnashevich@gmail.com> writes:
> Is there any trick to craft the query in such a way, so that to make the 
> optimizer believe that the filters would not remove any rows, and all 
> rows will likely be returned by the query?

If you don't mind writing some C code, you could create a dummy operator
that just returns its boolean argument, and attach a selectivity estimator
to it that returns 1.0.  Then you'd write the query as, perhaps,

WHERE ~~~(securityFilter1) AND ...

where ~~~ could be read as "likely()".  I wouldn't recommend using such a
wrapper for any WHERE clause that the optimizer had any intelligence about
at all, because it would defeat all of that.  But in this case you're
not getting any wins anyhow, so burying an opaque subselect in another
layer of opacity won't hurt.

            regards, tom lane


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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: How to fetch data from tables in PostgreSQL
Следующее
От: Melvin Davidson
Дата:
Сообщение: Re: How to fetch data from tables in PostgreSQL