IN vs equality (was Re: odd intermittent query hanging issue)

Поиск
Список
Период
Сортировка
От Chris Angelico
Тема IN vs equality (was Re: odd intermittent query hanging issue)
Дата
Msg-id CAPTjJmokvqy9Dvh1zgTcKC5hfGP-oUdreLhczUqLYcwCOVuZCg@mail.gmail.com
обсуждение исходный текст
Ответы Re: IN vs equality (was Re: odd intermittent query hanging issue)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
On Sat, May 19, 2012 at 3:09 AM, Steve Crawford
<scrawford@pinpointresearch.com> wrote:
> I also don't understand the "xcrm.channel_id in (1)" instead of
> "xcrm.channel_id = 1" unless this is a generated query and there could be
> multiple ids in that condition.

Side point from this thread. Is there ever any difference between
these two constructs? I often write code that generates queries, and I
could script it to "optimize down" to equality in the special case of
one to compare against, but generally don't bother. Normally my query
plans look equivalent, but is it less efficient in the query
optimizer? Obviously there's the readability issue, if you're
hand-writing SQL. Definitely better to be clear about what you mean.
But we script-craft SQL all the time (and it comes out (looking (like
this)) with all (the extra (parentheses) added) for safety).

ChrisA

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

Предыдущее
От: c k
Дата:
Сообщение: suggestion for backup
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: timestamps, formatting, and internals