Friday, June 18, 2010

Figuring out mysql slow queries

A good way to figure out what is going on is to take the slow queries and ask MySQL why they took so long. If you have phpmyadmin, open the query window (SQL button when you have the database up), and enter the slow query, preceded by "EXPLAIN", as in:


EXPLAIN SELECT  * FROM `phpbb_search_wordmatch`;
        table: phpbb_search_wordmatch
         type: ALL
possible_keys: NULL
          key: NULL
      key_len: NULL
          ref: NULL
         rows: 97
        Extra:

Usually, though, if you've got sufficient memory allocated to MySQL, this isn't a big factor. You might also look at your Apache configuration, to make sure it's not stopping to do reverse-DNS lookups unnecessarily.

No comments: