639
Chapter 8. Optimization
Table of Contents
8.1. Optimization Overview ........................................................................................................ 640
8.1.1. MySQL Design Limitations and Tradeoffs ................................................................. 640
8.1.2. Designing Applications for Portability ........................................................................ 640
8.1.3. The MySQL Benchmark Suite .................................................................................. 641
8.1.4. Using Your Own Benchmarks .................................................................................. 642
8.2. Obtaining Query Execution Plan Information ........................................................................ 643
8.2.1. Optimizing Queries with
EXPLAIN
............................................................................ 643
8.2.2.
EXPLAIN
Output Format .......................................................................................... 643
8.2.3.
EXPLAIN EXTENDED
Output Format ........................................................................ 652
8.2.4. Estimating Query Performance ................................................................................. 654
8.3. Optimizing SQL Statements ................................................................................................ 654
8.3.1. Optimizing
SELECT
Statements ................................................................................ 654
8.3.2. Optimizing Non-
SELECT
Statements ......................................................................... 685
8.3.3. Other Optimization Tips ........................................................................................... 689
8.4. Controlling the Query Optimizer .......................................................................................... 691
8.5. Optimization and Indexes ................................................................................................... 692
8.5.1. Column Indexes ...................................................................................................... 692
8.5.2. Multiple-Column Indexes .......................................................................................... 692
8.5.3. How MySQL Uses Indexes ...................................................................................... 694
8.5.4.
MyISAM
Index Statistics Collection ........................................................................... 696
8.6. Buffering and Caching ........................................................................................................ 698
8.6.1. The
MyISAM
Key Cache .......................................................................................... 698
8.6.2. The
InnoDB
Buffer Pool .......................................................................................... 702
8.6.3. The MySQL Query Cache ........................................................................................ 703
8.7. Locking Issues ................................................................................................................... 709
8.7.1. Internal Locking Methods ......................................................................................... 709
8.7.2. Table Locking Issues ............................................................................................... 711
8.7.3. Concurrent Inserts ................................................................................................... 712
8.7.4. External Locking ...................................................................................................... 713
8.8. Optimizing Database Structure ............................................................................................ 714
8.8.1. Make Your Data as Small as Possible ...................................................................... 714
8.8.2. Using
PROCEDURE ANALYSE
................................................................................... 715
8.8.3. How MySQL Opens and Closes Tables .................................................................... 716
8.8.4. Disadvantages of Creating Many Tables in the Same Database ................................. 717
8.8.5. How MySQL Uses Internal Temporary Tables ........................................................... 717
8.9. Optimizing the MySQL Server ............................................................................................. 718
8.9.1. System Factors and Startup Parameter Tuning ......................................................... 718
8.9.2. Tuning Server Parameters ....................................................................................... 718
8.9.3. How MySQL Uses Threads for Client Connections .................................................... 723
8.9.4. How MySQL Uses Memory ...................................................................................... 724
8.9.5. Disk Issues ............................................................................................................. 725
8.9.6. Using Symbolic Links ............................................................................................... 726
8.9.7. Enabling Large Page Support .................................................................................. 729
8.9.8. DNS Lookup Optimization and the Host Cache ......................................................... 730
8.10. Examining Thread Information ........................................................................................... 731
8.10.1. Thread Command Values ....................................................................................... 732
8.10.2. General Thread States ........................................................................................... 734
8.10.3. Delayed-Insert Thread States ................................................................................. 739
8.10.4. Query Cache Thread States ................................................................................... 740
8.10.5. Replication Master Thread States ........................................................................... 740
8.10.6. Replication Slave I/O Thread States ....................................................................... 741
8.10.7. Replication Slave SQL Thread States ..................................................................... 742
Summary of Contents for 5.0
Page 1: ...MySQL 5 0 Reference Manual ...
Page 18: ...xviii ...
Page 60: ...40 ...
Page 396: ...376 ...
Page 578: ...558 ...
Page 636: ...616 ...
Page 844: ...824 ...
Page 1234: ...1214 ...
Page 1427: ...MySQL Proxy Scripting 1407 ...
Page 1734: ...1714 ...
Page 1752: ...1732 ...
Page 1783: ...Configuring Connector ODBC 1763 ...
Page 1793: ...Connector ODBC Examples 1773 ...
Page 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Page 2850: ...2830 ...
Page 2854: ...2834 ...
Page 2928: ...2908 ...
Page 3000: ...2980 ...
Page 3122: ...3102 ...
Page 3126: ...3106 ...
Page 3174: ...3154 ...
Page 3232: ...3212 ...