Yesterday and today I gave a couple webinars on basic performance tuning of SQL queries and schema/index strategies. I've given this presentation quite a few times now, and a number of good questions always seem to come up. I figured I would summarize them and their answers in a blog post.
Q: Which will be faster out of these two queries?
SELECT ... WHERE some_col IN (1,2,3) or
SELECT ... WHERE some_col = 1 OR some_col = 2 OR some_col
= 3
A:
Neither. The optimizer rewrites an IN() operator to a series of OR conditions, so there will be no performance diffference. Use IN() as it makes the code shorter and more readable.
Q: Where does MyISAM cache table records? A:
Nowhere. MyISAM does not cache table records like InnoDB does in it's innodb_buffer_pool. Instead, MyISAM relies on the operating system buffering to buffer table records as it reads …
[Read more]