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.

Reply

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options