Optimization, Backups, and Replication
1234567

How can you bring out MySQL’s full power? With High Performance MySQL, you’ll learn advanced techniques for everything from designing schemas, indexes, and queries to tuning your MySQL server, operating system, and hardware to their fullest potential. This guide also teaches you safe and practical ways to scale applications through replication, load balancing, high availability, and failover.

Updated to reflect recent advances in MySQL and InnoDB performance, features, and tools, this third edition not only offers specific examples of how MySQL works, it also teaches you why this system works as it does, with illustrative stories and case studies that demonstrate MySQL’s principles in action. With this book, you’ll learn how to think in MySQL.

  • Learn the effects of new features in MySQL 5.5, including stored procedures, partitioned databases, triggers, and views
  • Implement improvements in replication, high availability, and clustering
  • Achieve high performance when running MySQL in the cloud
  • Optimize advanced querying features, such as full-text searches
  • Take advantage of modern multi-core CPUs and solid-state disks
  • Explore backup and recovery strategies—including new tools for hot online backups

Baron Schwartz

Baron Schwartz is Chief Performance Architect at Percona. He createstools and techniques to make MySQL easier to use and more dependable,and speaks regularly at conferences worldwide. He lives in Virginia with his family.

Peter Zaitsev

Peter managed the High Performance Group within MySQL until 2006, when he founded Percona. Peter has a Master's Degree in Computer Science and is an expert in database kernels, computer hardware, and application scaling. He serves as CEO of Percona, while keeping touch with his technical roots by continuing to do consulting for key customers.

Vadim Tkachenko

Vadim Tkachenko is the CTO and co-founder of Percona, and an authoron the MySQLPerformanceBlog.com and SSDPerformanceBlog.com blogs. Vadim leads Percona's development group, which produces the Percona Server, Percona XtraDB Cluster, and Percona XtraBackup.

  1. Chapter 1: MySQL Architecture and History

    1. MySQL’s Logical Architecture

    2. Concurrency Control

    3. Transactions

    4. Multiversion Concurrency Control

    5. MySQL’s Storage Engines

    6. A MySQL Timeline

    7. MySQL’s Development Model

    8. Summary

  2. Chapter 2: Benchmarking MySQL

    1. Why Benchmark?

    2. Benchmarking Strategies

    3. Benchmarking Tactics

    4. Benchmarking Tools

    5. Benchmarking Examples

    6. Summary

  3. Chapter 3: Profiling Server Performance

    1. Introduction to Performance Optimization

    2. Profiling Your Application

    3. Profiling MySQL Queries

    4. Diagnosing Intermittent Problems

    5. Other Profiling Tools

    6. Summary

  4. Chapter 4: Optimizing Schema and Data Types

    1. Choosing Optimal Data Types

    2. Schema Design Gotchas in MySQL

    3. Normalization and Denormalization

    4. Cache and Summary Tables

    5. Speeding Up ALTER TABLE

    6. Summary

  5. Chapter 5: Indexing for High Performance

    1. Indexing Basics

    2. Benefits of Indexes

    3. Indexing Strategies for High Performance

    4. An Indexing Case Study

    5. Index and Table Maintenance

    6. Summary

  6. Chapter 6: Query Performance Optimization

    1. Why Are Queries Slow?

    2. Slow Query Basics: Optimize Data Access

    3. Ways to Restructure Queries

    4. Query Execution Basics

    5. Limitations of the MySQL Query Optimizer

    6. Query Optimizer Hints

    7. Optimizing Specific Types of Queries

    8. Case Studies

    9. Summary

  7. Chapter 7: Advanced MySQL Features

    1. Partitioned Tables

    2. Views

    3. Foreign Key Constraints

    4. Storing Code Inside MySQL

    5. Cursors

    6. Prepared Statements

    7. User-Defined Functions

    8. Plugins

    9. Character Sets and Collations

    10. Full-Text Searching

    11. Distributed (XA) Transactions

    12. The MySQL Query Cache

    13. Summary

  8. Chapter 8: Optimizing Server Settings

    1. How MySQL’s Configuration Works

    2. What Not to Do

    3. Creating a MySQL Configuration File

    4. Configuring Memory Usage

    5. Configuring MySQL’s I/O Behavior

    6. Configuring MySQL Concurrency

    7. Workload-Based Configuration

    8. Completing the Basic Configuration

    9. Safety and Sanity Settings

    10. Advanced InnoDB Settings

    11. Summary

  9. Chapter 9: Operating System and Hardware Optimization

    1. What Limits MySQL’s Performance?

    2. How to Select CPUs for MySQL

    3. Balancing Memory and Disk Resources

    4. Solid-State Storage

    5. Choosing Hardware for a Replica

    6. RAID Performance Optimization

    7. Storage Area Networks and Network-Attached Storage

    8. Using Multiple Disk Volumes

    9. Network Configuration

    10. Choosing an Operating System

    11. Choosing a Filesystem

    12. Choosing a Disk Queue Scheduler

    13. Threading

    14. Swapping

    15. Operating System Status

    16. Summary

  10. Chapter 10: Replication

    1. Replication Overview

    2. Setting Up Replication

    3. Replication Under the Hood

    4. Replication Topologies

    5. Replication and Capacity Planning

    6. Replication Administration and Maintenance

    7. Replication Problems and Solutions

    8. How Fast Is Replication?

    9. Advanced Features in MySQL Replication

    10. Other Replication Technologies

    11. Summary

  11. Chapter 11: Scaling MySQL

    1. What Is Scalability?

    2. Scaling MySQL

    3. Load Balancing

    4. Summary

  12. Chapter 12: High Availability

    1. What Is High Availability?

    2. What Causes Downtime?

    3. Achieving High Availability

    4. Avoiding Single Points of Failure

    5. Failover and Failback

    6. Summary

  13. Chapter 13: MySQL in the Cloud

    1. Benefits, Drawbacks, and Myths of the Cloud

    2. The Economics of MySQL in the Cloud

    3. MySQL Scaling and HA in the Cloud

    4. The Four Fundamental Resources

    5. MySQL Performance in Cloud Hosting

    6. MySQL Database as a Service (DBaaS)

    7. Summary

  14. Chapter 14: Application-Level Optimization

    1. Common Problems

    2. Web Server Issues

    3. Caching

    4. Extending MySQL

    5. Alternatives to MySQL

    6. Summary

  15. Chapter 15: Backup and Recovery

    1. Why Backups?

    2. Defining Recovery Requirements

    3. Designing a MySQL Backup Solution

    4. Managing and Backing Up Binary Logs

    5. Backing Up Data

    6. Recovering from a Backup

    7. Backup and Recovery Tools

    8. Scripting Backups

    9. Summary

  16. Chapter 16: Tools for MySQL Users

    1. Interface Tools

    2. Command-Line Utilities

    3. SQL Utilities

    4. Monitoring Tools

    5. Summary

  17. Appendix : Forks and Variants of MySQL

    1. Percona Server

    2. MariaDB

    3. Drizzle

    4. Other MySQL Variants

    5. Summary

  18. Appendix : MySQL Server Status

    1. System Variables

    2. SHOW STATUS

    3. SHOW ENGINE INNODB STATUS

    4. SHOW PROCESSLIST

    5. SHOW ENGINE INNODB MUTEX

    6. Replication Status

    7. The INFORMATION_SCHEMA

    8. The Performance Schema

    9. Summary

  19. Appendix : Transferring Large Files

    1. Copying Files

    2. File Copy Benchmarks

  20. Appendix : Using EXPLAIN

    1. Invoking EXPLAIN

    2. The Columns in EXPLAIN

    3. Tree-Formatted Output

    4. Improvements in MySQL 5.6

  21. Appendix : Debugging Locks

    1. Lock Waits at the Server Level

    2. Lock Waits in InnoDB

  22. Appendix : Using Sphinx with MySQL

    1. A Typical Sphinx Search

    2. Why Use Sphinx?

    3. Architectural Overview

    4. Special Features

    5. Practical Implementation Examples

    6. Summary

  23. Colophon