Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ANY instead of IN for SQL query with variable placeholders
Since enabling pg_stat_statements we are seeing lots of queries like this on OSD with a variable number of placeholders at the top of the list: ``` SELECT me.job_id, me.key, me.value FROM job_settings me WHERE ( job_id IN ( $1, $2, $3, $4 ...many more ``` This patch replaces IN with ANY, which uses an array to pass the values and therefore only requires one prepared SQL query like: ``` SELECT me.job_id, me.key, me.value FROM job_settings me WHERE ( job_id = ANY(?) ); ``` Under ideal circumstances both should actually result in the exact same query plan. But under less than ideal circumstances the ANY variant should be a little more reliable, since there is only one version for the query planner to keep track of. And of course it won't clutter up our pg_stat_statements statistics.
- Loading branch information