Sample Header Ad - 728x90
When selecting a number of records from a Postgres table based on a list of ids passed as a parameter, what are the benefits and drawbacks of
-sql
SELECT id, 
FROM tbl
INNER JOIN UNNEST($1) AS id USING (id)
versus
-sql
SELECT id, 
FROM tbl
WHERE id = ANY($1)
and in which cases one should be preferred to the other? DB: Postgres 14 and above. **Note:** This is not a duplicate of https://dba.stackexchange.com/q/260856/193683 since the list is not constant.
Asked by Alex O (123 rep)
Oct 4, 2024, 07:54 PM
Last activity: Oct 4, 2024, 09:20 PM