Tag: queries

  • MySQL Database optimization

    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:

    1. Use EXPLAIN to profile the query execution plan
    2. Use Slow Query Log (always have it on!)
    3. Don’t use DISTINCT when you have or could use GROUP BY
    4. Insert performance
      1. Batch INSERT and REPLACE
      2. Use LOAD DATA instead of INSERT
    5. LIMIT m,n may not be as fast as it sounds
    6. Don’t use ORDER BY RAND() if you have > ~2K records (more…)