Just to have them all in one place, and for posterity’s sake, I’ve pulled together some points on how to optimise your MySQL programming.
First off, the result of Session 1 of MySQL Camp 1:
- Use EXPLAIN to profile the query execution plan
- Use Slow Query Log (always have it on!)
- Don’t use DISTINCT when you have or could use GROUP BY
- Insert performance
- Batch INSERT and REPLACE
- Use LOAD DATA instead of INSERT
- LIMIT m,n may not be as fast as it sounds
- Don’t use ORDER BY RAND() if you have > ~2K records (more…)