Y
Hacker News
new
|
ask
|
show
|
jobs
by
frollogaston
408 days ago
Yes, according to the manual, IN is equivalent to = ANY()
https://www.postgresql.org/docs/current/functions-subquery.h...
I had to check because for some reason, I always thought =ANY was somehow better than IN.
3 comments
Sesse__
408 days ago
IN is fine. The biggest problem comes with NOT IN, which has NULL semantics that makes life difficult for the planner. It is consistent but rarely what the user wants. NOT EXISTS is typically better there.
link
tczMUFlmoNk
408 days ago
ANY can be used with arrays, particularly query parameters: `id = ANY($1::int[])`, but not `id IN $1::int[]`.
link
frollogaston
407 days ago
Oh that must be why I got into this habit.
link
masklinn
408 days ago
It is, but in a pretty minor way: any can be used with no items, IN can not and will error.
link