Differences between = ANY and IN?

From: Maciek Sakrejda <m(dot)sakrejda(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Differences between = ANY and IN?
Date: 2023-10-03 05:01:53
Message-ID: CAOtHd0BNMci_2ZyoTKuCvOrrtebi==vwKU0PsqhX=DucfVmNEg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello,

My colleague has been working on submitting a patch [1] to the Ruby
Rails framework to address some of the problems discussed in [2].
Regardless of whether that change lands, the change in Rails would be
useful since people will be running Postgres versions without this
patch for a while.

My colleague's patch changes SQL generated from Ruby expressions like
`where(id: [1, 2])` . This is currently translated to roughly `WHERE
id IN (1, 2)` and would be changed to `id = ANY('{1,2}')`.

As far as we know, the expressions are equivalent, but we wanted to
double-check: are there any edge cases to consider here (other than
the pg_stat_statements behavior, of course)?

Thanks,
Maciek

[1]: https://github.com/rails/rails/pull/49388
[2]: https://www.postgresql.org/message-id/flat/20230209172651.cfgrebpyyr72h7fv%40alvherre.pgsql#eef3c77bc28b9922ea6b9660b0221b5d

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2023-10-03 05:02:10 Re: Making aggregate deserialization (and WAL receive) functions slightly faster
Previous Message Dilip Kumar 2023-10-03 04:42:36 Re: [PoC] pg_upgrade: allow to upgrade publisher node