Synopses & Reviews
How can you bring out MySQLs full power? With High Performance MySQL, youll 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 MySQLs principles in action. With this book, youll 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
High Performance MySQL teaches you advanced techniques in depth so you can bring out MySQL's full power. Learn how to design schemas, indexes, queries, and advanced MySQL features for maximum performance, and get detailed guidance for tuning your MySQL server, operating system, and hardware to their fullest potential. You'll also learn practical, safe, high-performance ways to scale your applications with replication, load balancing, high availability, and failover.
This third edition is completely revised and reflects recent advances in MySQL and InnoDB performance, features, and tools. Major additions include:
- Achieving high performance with MySQL in the cloud
- Using the new features in MySQL 5.5
- Taking advantage of modern multi-core CPUs and solid-state disks
- Improvements in replication, high availability, and new clustering options
- New tools for hot online backups
The book also includes chapters on benchmarking, profiling, backups, cloud computing, solid-state disks, and tools and techniques to help you measure, monitor, and manage your MySQL installations.
About the Author
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 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 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.
Table of Contents
Foreword; Preface; How This Book Is Organized; Software Versions and Availability; Conventions Used in This Book; Using Code Examples; Safari® Books Online; How to Contact Us; Acknowledgments for the Third Edition; Acknowledgments for the Second Edition; Acknowledgments for the First Edition; Chapter 1: MySQL Architecture and History; 1.1 MySQL's Logical Architecture; 1.2 Concurrency Control; 1.3 Transactions; 1.4 Multiversion Concurrency Control; 1.5 MySQL's Storage Engines; 1.6 A MySQL Timeline; 1.7 MySQL's Development Model; 1.8 Summary; Chapter 2: Benchmarking MySQL; 2.1 Why Benchmark?; 2.2 Benchmarking Strategies; 2.3 Benchmarking Tactics; 2.4 Benchmarking Tools; 2.5 Benchmarking Examples; 2.6 Summary; Chapter 3: Profiling Server Performance; 3.1 Introduction to Performance Optimization; 3.2 Profiling Your Application; 3.3 Profiling MySQL Queries; 3.4 Diagnosing Intermittent Problems; 3.5 Other Profiling Tools; 3.6 Summary; Chapter 4: Optimizing Schema and Data Types; 4.1 Choosing Optimal Data Types; 4.2 Schema Design Gotchas in MySQL; 4.3 Normalization and Denormalization; 4.4 Cache and Summary Tables; 4.5 Speeding Up ALTER TABLE; 4.6 Summary; Chapter 5: Indexing for High Performance; 5.1 Indexing Basics; 5.2 Benefits of Indexes; 5.3 Indexing Strategies for High Performance; 5.4 An Indexing Case Study; 5.5 Index and Table Maintenance; 5.6 Summary; Chapter 6: Query Performance Optimization; 6.1 Why Are Queries Slow?; 6.2 Slow Query Basics: Optimize Data Access; 6.3 Ways to Restructure Queries; 6.4 Query Execution Basics; 6.5 Limitations of the MySQL Query Optimizer; 6.6 Query Optimizer Hints; 6.7 Optimizing Specific Types of Queries; 6.8 Case Studies; 6.9 Summary; Chapter 7: Advanced MySQL Features; 7.1 Partitioned Tables; 7.2 Views; 7.3 Foreign Key Constraints; 7.4 Storing Code Inside MySQL; 7.5 Cursors; 7.6 Prepared Statements; 7.7 User-Defined Functions; 7.8 Plugins; 7.9 Character Sets and Collations; 7.10 Full-Text Searching; 7.11 Distributed (XA) Transactions; 7.12 The MySQL Query Cache; 7.13 Summary; Chapter 8: Optimizing Server Settings; 8.1 How MySQL's Configuration Works; 8.2 What Not to Do; 8.3 Creating a MySQL Configuration File; 8.4 Configuring Memory Usage; 8.5 Configuring MySQL's I/O Behavior; 8.6 Configuring MySQL Concurrency; 8.7 Workload-Based Configuration; 8.8 Completing the Basic Configuration; 8.9 Safety and Sanity Settings; 8.10 Advanced InnoDB Settings; 8.11 Summary; Chapter 9: Operating System and Hardware Optimization; 9.1 What Limits MySQL's Performance?; 9.2 How to Select CPUs for MySQL; 9.3 Balancing Memory and Disk Resources; 9.4 Solid-State Storage; 9.5 Choosing Hardware for a Replica; 9.6 RAID Performance Optimization; 9.7 Storage Area Networks and Network-Attached Storage; 9.8 Using Multiple Disk Volumes; 9.9 Network Configuration; 9.10 Choosing an Operating System; 9.11 Choosing a Filesystem; 9.12 Choosing a Disk Queue Scheduler; 9.13 Threading; 9.14 Swapping; 9.15 Operating System Status; 9.16 Summary; Chapter 10: Replication; 10.1 Replication Overview; 10.2 Setting Up Replication; 10.3 Replication Under the Hood; 10.4 Replication Topologies; 10.5 Replication and Capacity Planning; 10.6 Replication Administration and Maintenance; 10.7 Replication Problems and Solutions; 10.8 How Fast Is Replication?; 10.9 Advanced Features in MySQL Replication; 10.10 Other Replication Technologies; 10.11 Summary; Chapter 11: Scaling MySQL; 11.1 What Is Scalability?; 11.2 Scaling MySQL; 11.3 Load Balancing; 11.4 Summary; Chapter 12: High Availability; 12.1 What Is High Availability?; 12.2 What Causes Downtime?; 12.3 Achieving High Availability; 12.4 Avoiding Single Points of Failure; 12.5 Failover and Failback; 12.6 Summary; Chapter 13: MySQL in the Cloud; 13.1 Benefits, Drawbacks, and Myths of the Cloud; 13.2 The Economics of MySQL in the Cloud; 13.3 MySQL Scaling and HA in the Cloud; 13.4 The Four Fundamental Resources; 13.5 MySQL Performance in Cloud Hosting; 13.6 MySQL Database as a Service (DBaaS); 13.7 Summary; Chapter 14: Application-Level Optimization; 14.1 Common Problems; 14.2 Web Server Issues; 14.3 Caching; 14.4 Extending MySQL; 14.5 Alternatives to MySQL; 14.6 Summary; Chapter 15: Backup and Recovery; 15.1 Why Backups?; 15.2 Defining Recovery Requirements; 15.3 Designing a MySQL Backup Solution; 15.4 Managing and Backing Up Binary Logs; 15.5 Backing Up Data; 15.6 Recovering from a Backup; 15.7 Backup and Recovery Tools; 15.8 Scripting Backups; 15.9 Summary; Chapter 16: Tools for MySQL Users; 16.1 Interface Tools; 16.2 Command-Line Utilities; 16.3 SQL Utilities; 16.4 Monitoring Tools; 16.5 Summary; Forks and Variants of MySQL; Percona Server; MariaDB; Drizzle; Other MySQL Variants; Summary; MySQL Server Status; System Variables; SHOW STATUS; SHOW ENGINE INNODB STATUS; SHOW PROCESSLIST; SHOW ENGINE INNODB MUTEX; Replication Status; The INFORMATION_SCHEMA; The Performance Schema; Summary; Transferring Large Files; Copying Files; File Copy Benchmarks; Using EXPLAIN; Invoking EXPLAIN; The Columns in EXPLAIN; Tree-Formatted Output; Improvements in MySQL 5.6; Debugging Locks; Lock Waits at the Server Level; Lock Waits in InnoDB; Using Sphinx with MySQL; A Typical Sphinx Search; Why Use Sphinx?; Architectural Overview; Special Features; Practical Implementation Examples; Summary; Colophon;