Finding Slow Queries


To optimize any application, you must first find out which parts of it take up the most execution time. There are a few ways to do this:

  • Observation: Frequently, the reason we notice that optimization is needed is that one particular query runs at the speed of continental drift .

  • Benchmarking: Test your application to see which parts of it are slow.

  • Slow query log: This log tracks slow queries, as you might expect from its name .

After a slow query has been identified, you can work out how it is being executed by MySQL by using the EXPLAIN statement and can take steps to optimize the query.

It is not usually necessary to attempt to speed up all queries in an application. Generally, only a small portion of your code takes up most of the execution time. Unless your system is very, very busy, the programming time spent attempting to accelerate parts that do not take much time is wasted .



MySQL Tutorial
MySQL Tutorial
ISBN: 0672325845
EAN: 2147483647
Year: 2003
Pages: 261

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net