Transcript
Copyright © 2011, Oracle and/or it affiliates. All rights reserved.
Disclaimer
This document contains proprietary information and is protected by copyright and
Author
Jeff Gorton
This document contains proprietary information and is protected by copyright and other intellectual property laws. You may copy and print this document solely for your own use in an Oracle training course. The document may not be modified or altered in any way. Except where your use constitutes "fair use" under copyright law, you may not use, share, download, upload, copy, print, display, perform, reproduce, publish, license, post, transmit, or distribute this document in whole or in part without the express authorization of Oracle.
The information contained in this document is subject to change without notice. If you find any problems in the document, please report them in writing to: Oracle University, 500 Oracle Parkway, Redwood Shores, California 94065 USA. This document is not
Technical Contributors and Reviewers
Paul DuboisJohn RussellJames DayKimseong LohMattias Jonsson
warranted to be error-free.
Restricted Rights Notice
If this documentation is delivered to the United States Government or anyone using the documentation on behalf of the United States Government, the following notice is applicable:
U.S. GOVERNMENT RIGHTSThe U.S. Government’s rights to use, modify, reproduce, release, perform, display, or disclose these training materials are restricted b the terms of the applicable Oracle
Mattias JonssonOle Solberg
Editors
MalavikaRichard Wallis
G hi D i disclose these training materials are restricted by the terms of the applicable Oracle license agreement and/or the applicable U.S. Government contract.
Trademark Notice
Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.
Graphic Designer
Maheshwari Krishnamurthy
Publishers
Jayanthy KeshavamurthyVeena Narasimhan
iii
Contents
Preface
1 Introduction Course Goals 1-2 Course Lesson Map 1-3 Introductions 1-5 Classroom Environment 1-6 MySQL: Overview 1-7 Acquisitions of the MySQL Company 1-8 MySQL Is Powering the World! 1-9 MySQL Database Server Editions 1-10 MySQL Tools 1-11 MySQL Drivers 1-12 MySQL Services 1-13 Community Support 1-14 Oracle Lifetime Support for MySQL 1-15 MySQL: Supported Operating Systems 1-16 MySQL Websites 1-17 MySQL Curriculum Footprint 1-18 MySQL Certifications: Overview 1-19 MySQL Online Documentation 1-20
2 Performance Tuning Basics
Objectives 2-2 Thinking About Performance 2-3 Areas to Tune 2-4 Performance Tuning Terminology 2-5 Quiz 2-10 Benchmark Planning 2-11 Benchmark Errors 2-13 Tuning Steps 2-15 General Tuning Session 2-16 Deploying MySQL 2-17 Quiz 2-19 Summary 2-20
iv
3 Performance Tuning Tools Objectives 3-2 MySQL Monitoring Tools 3-3 Practice 3-1 Overview: MySQL Monitoring Tools 3-5 Quiz 3-6 Open Source Community Monitoring Tools 3-7 Practice 3-2 Overview: Open Source Community Monitoring Tools 3-10 Quiz 3-11 Benchmark Tools 3-12 Stress Tools 3-14 Practice 3-3 Overview: Benchmark Tools 3-15 Quiz 3-16 Summary 3-17
4 MySQL Server Tuning
Objectives 4-2 Major Components of the MySQL Server 4-3 Quiz 4-4 MySQL Thread Handling 4-5 Quiz 4-6 MySQL Memory Usage 4-7 Quiz 4-8 Simultaneous Connections in MySQL 4-9 Quiz 4-11 Reusing Threads 4-12 Thread Cache: Scenario 4-14 Practice 4-1 Overview: Effects of Thread Caching 4-15 Reusing Tables 4-16 Setting table_open_cache 4-17 Setting table_open_cache: Scenario 1 4-18 Setting table_open_cache: Scenario 2 4-19 Setting table_open_cache: Scenario 3 4-20 Practice 4-2 Overview: Table Caching 4-21 Quiz 4-22 Managing Files 4-23 Quiz 4-26 Practice 4-4 Overview: Setting max_connections 4-27 Other Connection Status Variables 4-28 Practice 4-5 Overview: Evaluating the Effect of Numerous Connections 4-29 Other Thread Status Variables 4-30 Setting thread_cache_size: Scenario 4-31
v
Per-Session Thread Buffers 4-32 Quiz 4-36 Total Thread Memory Usage 4-37 Total Thread Memory Usage: Scenario 4-38 Practice 4-6 Overview: Total Thread Memory Usage 4-39 Optimal Sorting of Data 4-40 Practice 4-7 Overview: Sort Queries 4-42 Network Problems 4-43 Quiz 4-44 Binary Logs Performance 4-45 Quiz 4-46 All Statements 4-47 Quiz 4-49 SELECT Statements 4-50 Quiz 4-52 Table Locks Performance 4-53 Quiz 4-54 Summary 4-55
5 MySQL Query Cache
Objectives 5-2 MySQL Query Cache 5-3 MySQL Query Cache Settings 5-4 When Not to Use the MySQL Query Cache 5-6 When to Use the MySQL Query Cache 5-7 Quiz 5-8 MySQL Query Cache Status Variables 5-9 Practice 5-1 Overview: Query Cache 5-12 Quiz 5-13 Improve Query Cache Results 5-14 Quiz 5-15 Summary 5-16
6 InnoDB
Objectives 6-2 InnoDB Storage Engine 6-3 InnoDB Storage Engine: Uses 6-4 Using the InnoDB Storage Engine 6-5 Quiz 6-7 InnoDB Log Files and Buffers 6-8 Quiz 6-9
vi
Practice 6-1 Overview: Commit Transactions 6-10 InnoDB Table Design 6-11 Quiz 6-13 SHOW ENGINE INNODB STATUS 6-14 Other SHOW ENGINE INNODB STATUS Sections 6-16 Practice 6-2 Overview: SHOW ENGINE INNODB STATUS 6-18 Quiz 6-19 InnoDB Monitors 6-20 Practice 6-3 Overview: InnoDB Monitors 6-21 Quiz 6-22 InnoDB Settings 6-23 Practice 6-4 Overview: InnoDB Settings 6-31 Quiz 6-32 Summary 6-33
7 MyISAM
Objectives 7-2 MyISAM Storage Engine 7-3 MyISAM Storage Engine: Uses 7-4 MyISAM Table Design 7-5 Quiz 7-6 Optimizing MyISAM 7-7 Practice 7-1 Overview: Optimize MyISAM 7-8 Quiz 7-9 Minimizing MyISAM Table Lock Issues 7-10 Practice 7-2 Overview: MyISAM Table Locks 7-12 MyISAM Settings 7-13 Quiz 7-15 MyISAM Key Cache 7-16 MyISAM Key Cache: Status Variables 7-18 Practice 7-3 Overview: Key Cache Effectiveness 7-20 Quiz 7-21 MyISAM Full-Text Search 7-22 MyISAM Full-Text Search: Tips 7-23 Practice 7-4 Overview: Full-Text Indexing 7-24 Summary 7-25
8 Other MySQL Storage Engines and Issues
Objectives 8-2 Large Objects 8-3 Practice 8-1 Overview: Large Objects 8-4
vii
Quiz 8-5 MEMORY Storage Engine 8-6 MEMORY Storage Engine: Uses 8-7 MEMORY Storage Engine: Performance 8-8 Practice 8-2 Overview: MEMORY Storage Engine 8-9 Quiz 8-10 Using Multiple Storage Engines: Advantages 8-11 Using a Single Storage Engine: Advantages 8-12 Quiz 8-13 Summary 8-14
9 Schema Design and Performance
Objectives 9-2 Schema Design Considerations 9-3 Schema Design Tasks 9-4 Quiz 9-6 Normalization and Performance 9-7 Non-Normalization and Performance 9-8 Mixing Normalization and Performance 9-9 Practice 9-1 Overview: Schema Design 9-11 Quiz 9-12 Data Types 9-13 Practice 9-2 Overview: Data Types 9-15 Quiz 9-16 Indexes 9-17 Indexing 9-19 Index Types 9-22 Practice 9-3 Overview: Indexes 9-23 Quiz 9-24 Partitioning 9-25 Partitioning and the File System 9-26 Other Partitioning Performance Issues 9-27 Partitioning Limitations 9-28 Practice 9-4 Overview: Partitioning 9-29 Quiz 9-30 Summary 9-31
10 MySQL Query Performance
Objectives 10-2 SQL Tuning: General Best Practices 10-3 Quiz 10-4
viii
EXPLAIN 10-5 Quiz 10-6 EXPLAIN Output 10-7 Quiz 10-9 EXPLAIN select_type 10-10 Quiz 10-11 EXPLAIN type 10-12 Quiz 10-15 EXPLAIN key 10-16 Quiz 10-17 EXPLAIN Extra 10-18 Quiz 10-20 Practice 10-1 Overview: EXPLAIN Outputs 10-21 MySQL Query Optimizer 10-22 Quiz 10-23 Finding Problematic Queries 10-24 Quiz 10-26 Practice 10-2 Overview: Improve Query Executions 10-27 Practice 10-3 Overview: Locate and Correct Problematic Queries 10-28 Summary 10-29
11 Performance Tuning Extras
Objectives 11-2 Hardware Considerations 11-3 Quiz 11-5 Hardware Considerations 11-6 Quiz 11-8 Configuring Hardware 11-9 Quiz 11-10 Operating System Considerations 11-11 Quiz 11-12 Operating System Configuration 11-13 Quiz 11-16 Logging 11-17 Quiz 11-18 Backup and Recovery 11-19 Quiz 11-20 Summary 11-21
ix
12 Conclusion Course Goals: Review (1 of 3) 12-2 Course Goals: Review (2 of 3) 12-3 Course Goals: Review (3 of 3) 12-4 MySQL Curriculum Path 12-5 MySQL Resources 12-6 We Need Your Evaluation! 12-7 Thank You! 12-8 Q&A Session 12-9
Appendix: Example Schema Data Models Appendix: Lab Scripts
Appendix: Appendix: Basic Linux vi Editor Commands
top related