IN vs equality (was Re: odd intermittent query hanging issue) - Mailing list pgsql-general

From Chris Angelico
Subject IN vs equality (was Re: odd intermittent query hanging issue)
Date
Msg-id CAPTjJmokvqy9Dvh1zgTcKC5hfGP-oUdreLhczUqLYcwCOVuZCg@mail.gmail.com
Whole thread Raw
Responses Re: IN vs equality (was Re: odd intermittent query hanging issue)
List 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 by date:

Previous
From: c k
Date:
Subject: suggestion for backup
Next
From: Adrian Klaver
Date:
Subject: Re: timestamps, formatting, and internals