I can’t stress enough that people look at SQL statements that are being executed against your production MySQL database, and you optimize queries when you can.
Often it’s the improvement to the large number of similar queries executed that can optimize resources. In this example, we take a very simple query, and by removing an unnecessary order by, we eliminate MySQL internally creating a temporary (in memory) table.
So what’s the big deal.
- The query is simpler to read and understand
- Memory required for the connection is not assigned
- A number of internal steps are no longer required (4 of 21 logging messages, not an ideal measurement, but an indication). In this case, it was easily a 10% performance improvement for each query.
This query is executed 10-100 times per second, so the improvement in performance is significant.
mysql> explain select max(mdate) …[Read more]