These are different request batching methods:
-
make 2 concurrent requests with 2 tcp connections:
session1 - “SELECT * FROM table WHERE key = 1;”
session2 - “SELECT * FROM table WHERE key = 2;” -
concatenate SQL statements with semicolons;
“SELECT * FROM table WHERE key = 1; SELECT * FROM table WHERE key = 2;” -
merge them with IN
“SELECT * FROM table WHERE key IN (1, 2);”
Are 1, 2 slower than 3 because they open/lock the table twice? Or immediately accessing the same table one after another is just as fast as 3?
What’s the best practice for performance? WHERE … IN cannot be used with inequalities so 3 cannot be generalized.