select * from table1 where primaryKey IN (select primaryKey from table2)
Assuming table2 has more than 1 row, the query will not use the primary key index for table1. Replace the subselect with the actual ids 1,2,3,etc and it will.
There is a difference in how the optimizer views certain clauses.
Try: select * from table1
Try:
select * from table1 where primaryKey IN (select primaryKey from table2)
Assuming table2 has more than 1 row, the query will not use the primary key index for table1. Replace the subselect with the actual ids 1,2,3,etc and it will.
There is a difference in how the optimizer views certain clauses.