How to improve performances for SQL queries with IN and thousands of values
Today I’ve had to optimize an SQL query with this structure:
A very simple query, but having thousands of values after
IN causes very bad performances.
Some Internet searches have allowed me to find an equivalent query to do that, but faster:
I’ve had to create a temporary table and insert into it all IDs and INNER JOIN it. Optionally, you can drop the table after the request, but the table lives only during the session anyway.