MySQL Reference Manual for version 4.0.18.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

7.2 Optimizing SELECT Statements and Other Queries

First, one thing that affects all queries: The more complex permission system setup you have, the more overhead you get.

If you do not have any GRANT statements done, MySQL will optimize the permission checking somewhat. So if you have a very high volume it may be worth the time to avoid grants. Otherwise, more permission check results in a larger overhead.

If your problem is with some explicit MySQL function, you can always time this in the MySQL client:

 
mysql> SELECT BENCHMARK(1000000,1+1);
+------------------------+
| BENCHMARK(1000000,1+1) |
+------------------------+
|                      0 |
+------------------------+
1 row in set (0.32 sec)

The above shows that MySQL can execute 1,000,000 + expressions in 0.32 seconds on a PentiumII 400MHz.

All MySQL functions should be very optimized, but there may be some exceptions, and the BENCHMARK(loop_count,expression) is a great tool to find out if this is a problem with your query.

7.2.1 EXPLAIN Syntax (Get Information About a SELECT)  
7.2.2 Estimating Query Performance  
7.2.3 Speed of SELECT Queries  
7.2.4 How MySQL Optimizes WHERE Clauses  
7.2.5 How MySQL Optimizes OR Clauses  
7.2.6 How MySQL Optimizes IS NULL  
7.2.7 How MySQL Optimizes DISTINCT  
7.2.8 How MySQL Optimizes LEFT JOIN and RIGHT JOIN  
7.2.9 How MySQL Optimizes ORDER BY  
7.2.10 How MySQL Optimizes LIMIT  
7.2.11 Speed of INSERT Queries  
7.2.12 Speed of UPDATE Queries  
7.2.13 Speed of DELETE Queries  
7.2.14 Other Optimization Tips  


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated by rdg (Feb 25 2004) using texi2html