MySQL Performance Tuning

Similar documents
MySQL Performance Tuning

Oracle Hyperion Data Relationship Management Administration Activity Guide

MySQL Cluster Student Guide

Oracle VM Administration: Oracle VM Server for x86 Student Guide

Oracle VM Server for x86: Administration

Oracle GoldenGate 11g: Advanced Configuration for Oracle Student Guide

Oracle Warehouse Builder 10g: Administration

Oracle Application Express: Administration Student Guide

MySQL for Database Administrators Volume I Student Guide

Oracle WebCenter Sites 11g for Developers

Oracle Forms Developer 10g: Move to the Web

Siebel 8.1.x Fundamentals Student Guide

Oracle Data Integrator: Administration and Development Volume I Student Guide

UNIX and Linux Essentials Student Guide

Oracle Application Testing Suite: Introduction Student Guide

Oracle Adaptive Access Manager: Administration Student Guide

Oracle WebLogic Server 11g: Overview for WLS Administrators

Oracle 11g: XML Fundamentals

Oracle Warehouse Builder 10g: New Features

Oracle SQL Tuning for Developers Workshop Student Guide - Volume I

Oracle Database 10g: New Features for Release 2 Overview Seminar

Oracle Service Bus 10g R3: Design & Integrate Services for SOA

Oracle Data Integrator 11g: Advanced Integration and Development Student Guide

Oracle Data Modeling and Relational Database Design Volume I Student Guide

Oracle Database 11g: Oracle Secure Backup

Oracle WebLogic Server 12c: JMS Administration Student Guide

Using Java - for PL/SQL and Database Developers Student Guide

Oracle GoldenGate 11g: Fundamentals for SQL Server Student Guide

Oracle Database 11g: SQL Tuning Workshop. Student Guide

Oracle Communication and Mobility Server: Introduction Student Guide

Oracle Database 10g: Using OLAP

Oracle Application Server 10g R2: Administration II

Oracle TimesTen 6.0: Core Concepts and Administration Volume I - Student Guide

Oracle Database 10g: Implementing Database Vault

Oracle Database 11g: SQL Fundamentals I

Oracle WebLogic Server 12c: Administration I

Oracle WebCenter Content 11g: Content Server Customization Student Guide - Volume I

Oracle Warehouse Builder 10g: Implementation Part 2

Oracle Content Server 11g: Administration

Oracle Exalogic Elastic Cloud 2.x: System Administration

Oracle Database 10g: Implement and Administer a Data Warehouse

Oracle Database 11g: Backup and Recovery Workshop

Oracle Database 10g: Data Guard Administration

Oracle BI 11g R1: Build Repositories

Oracle Database 11g: Use XML DB

Oracle Database 12c: Install and Upgrade Workshop

Oracle Application Server 10g R3: Administration

Oracle BI Publisher 11g R1: Fundamentals

MySQL and PHP - Developing Dynamic Web Applications

Oracle Data Integrator 11g: Integration and Administration Student Guide - Volume I

Java Performance Tuning and Optimization Student Guide

OracleAS 10g R3: Java Programming

Oracle Database 10g: SQL Fundamentals I

Oracle TimesTen 7.0: IMDB, Cache Connect, and Replication Volume I Student Guide

Oracle BPM 10g R3 Programming 1 Essentials

Java Programming Language

Oracle Spatial: Advanced Student Guide

Oracle Service Bus 10g R3: System Administration

Oracle GoldenGate 11g Fundamentals for Oracle

Sun Virtualization: Solaris 10 Containers Administration

E Oracle 10g Java Bootcamp I v1

Oracle 10g: Java Programming

OracleAS 10g R3: Build J2EE Applications II

Oracle Database 11g: Data Guard Administration

R12.x Oracle Order Management Fundamentals Student Guide

Oracle BI Publisher 10g R3: Fundamentals

Oracle Database 10g: PL/SQL Fundamentals

Oracle TimesTen 6.0: Core Concepts and Administration Volume I Student Guide

Analytics: Server Architect (Siebel 7.7)

Fundamentals of the Java Programming Language

E Oracle 10g Java Bootcamp II v1

Oracle Database 10g: PL/SQL Fundamentals

Sun Java System Application Server 8.1: Administration & Deployment

Oracle Spatial 10g: Advanced

Oracle Database 12c: SQL Tuning for Developers

R12.x Oracle Subledger Accounting Fundamentals Student Guide

Oracle Identity Manager 11g: Essentials

MySQL for Developers. Student Guide - Volume 1. SQL-4501 Release 2.2. D61830GC10 Edition 1.0 D62436

Delegates must have a working knowledge of MariaDB or MySQL Database Administration.

Shell Programming for System Administrators Student Guide

Oracle WebLogic Server 11g: Diagnostics and Troubleshooting

Oracle9i Database: Advanced Instance Tuning

Copyright 1998, 2009, Oracle and/or its affiliates. All rights reserved.

Business Component Development with EJB Technology, Java EE 5

Oracle Database 11g: RAC Administration

Java EE Patterns. Student Guide - Volume 1. SL-500 Rev C.0.1. D61856GC10 Edition 1.0 D62465

Sun Certified System Administrator for the Solaris 10 OS Bootcamp

Oracle Communications Configuration Management

Primavera Portfolio Management Reporting Views for SQL Server databases

Oracle SOA Suite 10g R3: Administration. Student Guide

Adaptive Risk Manager Challenge Question Cleanup 10g ( ) December 2007

MySQL and Virtualization Guide

Oracle Database 12c: Administration Workshop

Administration Guide Release 5.0

Oracle Application Express

Secure Configuration Guide

Oracle Customer Care. Implementation Guide. Release 11i. August, 2000 Part No. A

CO MySQL for Database Administrators

JD Edwards EnterpriseOne Licensing

Oracle SQL Developer. Oracle TimesTen In-Memory Database Support User's Guide Release 4.0 E

Transcription:

MySQL Performance Tuning Student Guide D61820GC20 Edition 2.0 May 2011 D73030

Author Jeff Gorton Copyright 2011, Oracle and/or it affiliates. All rights reserved. Disclaimer Technical Contributors and Reviewers Paul Dubois John Russell James Day Kimseong Loh Mattias Jonsson Ole Solberg Editors Malavika Richard Wallis 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 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 RIGHTS The 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 license agreement and/or the applicable U.S. Government contract. Graphic Designer disclose these training materials are restricted by the terms of the applicable Oracle Maheshwari Krishnamurthy Publishers Jayanthy Keshavamurthy Veena Narasimhan Trademark Notice Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners.

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 iii

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 iv

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 v

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 vi

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 vii

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 viii

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 ix