Re: BUG #16251: ::text type casting of a constant breaks query performance

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: BUG #16251: ::text type casting of a constant breaks query performance
Дата
Msg-id CAMkU=1zcy8fX_XEQVvETD779GnMc=g_yBpftdFS_pcG9ShDGZw@mail.gmail.com
обсуждение исходный текст
Ответ на Re: BUG #16251: ::text type casting of a constant breaks query performance  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Sat, Feb 8, 2020 at 11:49 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Pavel Stehule <pavel.stehule@gmail.com> writes:
> so 8. 2. 2020 v 7:44 odesílatel PG Bug reporting form <
> noreply@postgresql.org> napsal:
 
If you can't rearrange things so that the IS NULL argument is seen
as a constant, the UNION trick that Pavel mentioned might be a useful
workaround.  But I'm inclined to think that you need to take two steps
back and figure out whether this query logic is really sane or not.
You do realize that the query is asking to retrieve the entire table,
if whatever-it-is is NULL?  Why would that be what you want?

It is a pretty common tactic to do this.  It much easier on the client side to bind NULL to a parameter when you don't care, rather than dynamically rewrite the query text to remove that condition from it.  Of course that whole thing is likely to be ANDed together with other clauses in an unsimplified real-world example.

Cheers,

Jeff

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

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: BUG #16252: PL/pgSQL dynamic programming not well suited forworking with different schemas
Следующее
От: PG Bug reporting form
Дата:
Сообщение: BUG #16253: Documentation bug https://www.postgresql.org/docs/12/auth-methods.html