PostgreSQL using ANY instead of IN
Posted on 2025-03-31 in Trucs et astuces • Tagged with PostgreSQL, Database
I recently learned while reading psycopg’s documentation (a Python driver for PostgreSQL), that you should use WHERE id = ANY(:values) instead of WHERE id IN :values when filtering over lists. That’s because the ANY operator works with empty list while IN doesn’t. Psycopg will also correctly adapt …
Continue reading