Synopses & Reviews
Now that MySQL has proven to be a robust product for large, demanding environments, both programmers and administrators want more information on how to get the most out of it. High Performance MySQL goes beyond the basics to explain how MySQL works under the hood so that experienced users can understand why it's fast and, conversely, what can slow it down. In this new edition, you'll learn how to maximize the speed and robustness of MySQL through advanced configuration, and methods to optimize everything from schemas, queries, server settings and applications to operating systems, and hardware -- topics that typical MySQL books don't cover very well. Other requirements for scaling MySQL, such as replication, backups, and load balancing, are thoroughly discussed as well. This is not a book on MySQL theory -- it's a collection of hands-on methods for solving real-world problems, by authors who have the experience to back it up. High Performance MySQL includes: Clustering solutions Impacts of new features of MySQL 5.0/5.1, including stored procedures, partitioned databases, triggers, and views Expanded comparisons of storage engines and optimization techniques specific to each one Federation (scaling by dividing data among different servers or different clusters) Optimization of subqueries Use of the new information schema to retrieve data about the server and your databases Optimization of advanced querying features, such as full text searches and the use of cursors With this book, you'll discover good practices for large demanding environments, and learn about MySQL's weaknesses and how to work around them. High Performance MySQL offers the advanced solutions you need to ensure asmoothly functioning database-driven website.
Users of MySQL find they have to deal with issues of reliability, scalability, and performance. This book is an insider's guide to these variables that are not well documented, but are critical to a smoothly functioning site.
High Performance MySQL is the definitive guide to building fast, reliable systems with MySQL. Written by noted experts with years of real-world experience building very large systems, this book covers every aspect of MySQL performance in detail, and focuses on robustness, security, and data integrity.
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 second edition is completely revised and greatly expanded, with deeper coverage in all areas. Major additions include:
- Emphasis throughout on both performance and reliability
- Thorough coverage of storage engines, including in-depth tuning and optimizations for the InnoDB storage engine
- Effects of new features in MySQL 5.0 and 5.1, including stored procedures, partitioned databases, triggers, and views
- A detailed discussion on how to build very large, highly scalable systems with MySQL
- New options for backups and replication
- Optimization of advanced querying features, such as full-text searches
- Four new appendices
The book also includes chapters on benchmarking, profiling, backups, security, and tools and techniques to help you measure, monitor, and manage your MySQL installations.
About the Author
Baron Schwartz is a software engineer who lives in Charlottesville, Virginia and goes by the online handle of "Xaprb," which is his first name typed in QWERTY on a Dvorak keyboard. When he's not busy solving a fun programming challenge, he relaxes with his wife Lynn and dog Carbon. He blogs about software engineering at http://www.xaprb.com/blog/.
A former manager of the High Performace Group at MySQL AB, Peter Zaitsev now runs the mysqlperformanceblog.com site. He specializes in helping administrators fix issues with Web sites handling millions of visitors a day, dealing with terabytes of data using hundreds of servers. He is used to making changes and upgrades both to hardware to software (such as query optimization) in order to find solutions. He also speaks frequently at conferences.
Vadim Tkachenko was a Performance Engineer in at MySQL AB. As an expert in multithreaded programming and synchronization, his primary tasks were benchmarks, profiling, and finding bottlenecks. He also worked on a number of features for performance monitoring and tuning, and getting MySQL to scale well on multiple CPUs.
Jeremy Zawodny and his two cats moved from Northwest Ohio to Silicon Valley in late 1999 so he could work for Yahoo!--just in time to witness the .com bubble bursting first-hand. He's been at Yahoo!® ever since, helping to put MySQL and other Open Source technologies to use in fun, interesting, and often very big ways. Starting with the popular and high-traffic Yahoo! Finance site, he worked to make MySQL part of the site's core infrastructure in large batch operations as well as real-time feed processing and serving content directly on the site. He then helped to spread "the MySQL religion" to numerous other groups within Yahoo!, including News, Personals, Sports, and Shopping. Nowadays he acts as Yahoo!'s MySQL guru, working with Yahoo!'s many engineering groups to get the most out of their MySQL deployments.
In 2000, he began writing for Linux Magazine and continues to do so today as a columnist and contributing editor. After over a year of active participation on the MySQL mailing list, he got the idea to write a book about MySQL. (How hard could it be, really?) You can still find him answering questions on the list today. Since 2001, Jeremy has been speaking about MySQL at various conferences (O'Reilly's Open Source Conference, PHPCon, The MySQL User Conference, etc.) and user groups in locations as far away as Bangalore, India. His favorite topics are performance tuning, replication, clustering, and backup/recovery. In more recent times, he's rediscovered his love of aviation, earning a Private Pilot Glider license in early 2003. Since then he's spent far too much of his free time flying gliders out of Hollister, California and Truckee, near Lake Tahoe. He hopes to soon earn his Commercial Pilot license and then go on to become a certified flight instructor someday. Occasional MySQL consulting also helps to pay for his flying addiction.
Jeremy rambles almost daily about technology and life in general on his weblog: www.jeremy.zawodny.com/blog/
Arjen Lentz was born in Amsterdam but has lived in Queensland Australia since the turn of the millennium, sharing his life these days with his beautiful daughter Phoebe and black cat Figaro. Originally a C programmer, Arjen was employee #25 at MySQL AB (2001-2007). After a brief break in 2007, Arjen founded Open Query (http://openquery.com.au), which develops and provides its own data management training and consulting services in the Asia Pacific region and beyond. Arjen also regularly speaks at conferences and user groups. In his abundant spare time Arjen indulges in cooking, gardening, reading, camping, and exploring the RepRap. Arjen's weblog is at http://arjen-lentz.livejournal.com/
Derek J. Balling has been a Linux system administrator since 1996. Hehas helped build and maintain server infrastructure for companies likeYahoo, and institutions like Vassar College. He has also writtenarticles for The Perl Journal and a number of online magazines, and ison the Program Committee for the 2008 LISA Conference. He is currentlyemployed as the Data Center Manager for Answers.com.
When not working on computer-related issues, Derek enjoys spendingtime with his wife Debbie, and their posse of animals (4 cats and adog). He also makes his opinion known on current events or whatever isannoying him lately on his blog at http://blog.megacity.org/.
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 Second Edition; Acknowledgments for the First Edition; Chapter 1: MySQL Architecture; 1.1 MySQL's Logical Architecture; 1.2 Concurrency Control; 1.3 Transactions; 1.4 Multiversion Concurrency Control; 1.5 MySQL's Storage Engines; Chapter 2: Finding Bottlenecks: Benchmarking and Profiling; 2.1 Why Benchmark?; 2.2 Benchmarking Strategies; 2.3 Benchmarking Tactics; 2.4 Benchmarking Tools; 2.5 Benchmarking Examples; 2.6 Profiling; 2.7 Operating System Profiling; Chapter 3: Schema Optimization and Indexing; 3.1 Choosing Optimal Data Types; 3.2 Indexing Basics; 3.3 Indexing Strategies for High Performance; 3.4 An Indexing Case Study; 3.5 Index and Table Maintenance; 3.6 Normalization and Denormalization; 3.7 Speeding Up ALTER TABLE; 3.8 Notes on Storage Engines; Chapter 4: Query Performance Optimization; 4.1 Slow Query Basics: Optimize Data Access; 4.2 Ways to Restructure Queries; 4.3 Query Execution Basics; 4.4 Limitations of the MySQL Query Optimizer; 4.5 Optimizing Specific Types of Queries; 4.6 Query Optimizer Hints; 4.7 User-Defined Variables; Chapter 5: Advanced MySQL Features; 5.1 The MySQL Query Cache; 5.2 Storing Code Inside MySQL; 5.3 Cursors; 5.4 Prepared Statements; 5.5 User-Defined Functions; 5.6 Views; 5.7 Character Sets and Collations; 5.8 Full-Text Searching; 5.9 Foreign Key Constraints; 5.10 Merge Tables and Partitioning; 5.11 Distributed (XA) Transactions; Chapter 6: Optimizing Server Settings; 6.1 Configuration Basics; 6.2 General Tuning; 6.3 Tuning MySQL's I/O Behavior; 6.4 Tuning MySQL Concurrency; 6.5 Workload-Based Tuning; 6.6 Tuning Per-Connection Settings; Chapter 7: Operating System and Hardware Optimization; 7.1 What Limits MySQL's Performance?; 7.2 How to Select CPUs for MySQL; 7.3 Balancing Memory and Disk Resources; 7.4 Choosing Hardware for a Slave; 7.5 RAID Performance Optimization; 7.6 Storage Area Networks and Network-Attached Storage; 7.7 Using Multiple Disk Volumes; 7.8 Network Configuration; 7.9 Choosing an Operating System; 7.10 Choosing a Filesystem; 7.11 Threading; 7.12 Swapping; 7.13 Operating System Status; Chapter 8: Replication; 8.1 Replication Overview; 8.2 Setting Up Replication; 8.3 Replication Under the Hood; 8.4 Replication Topologies; 8.5 Replication and Capacity Planning; 8.6 Replication Administration and Maintenance; 8.7 Replication Problems and Solutions; 8.8 How Fast Is Replication?; 8.9 The Future of MySQL Replication; Chapter 9: Scaling and High Availability; 9.1 Terminology; 9.2 Scaling MySQL; 9.3 Load Balancing; 9.4 High Availability; Chapter 10: Application-Level Optimization; 10.1 Application Performance Overview; 10.2 Web Server Issues; 10.3 Caching; 10.4 Extending MySQL; 10.5 Alternatives to MySQL; Chapter 11: Backup and Recovery; 11.1 Overview; 11.2 Considerations and Tradeoffs; 11.3 Managing and Backing Up Binary Logs; 11.4 Backing Up Data; 11.5 Recovering from a Backup; 11.6 Backup and Recovery Speed; 11.7 Backup Tools; 11.8 Scripting Backups; Chapter 12: Security; 12.1 Terminology; 12.2 Account Basics; 12.3 Operating System Security; 12.4 Network Security; 12.5 Data Encryption; 12.6 MySQL in a chrooted Environment; Chapter 13: MySQL Server Status; 13.1 System Variables; 13.2 SHOW STATUS; 13.3 SHOW INNODB STATUS; 13.4 SHOW PROCESSLIST; 13.5 SHOW MUTEX STATUS; 13.6 Replication Status; 13.7 INFORMATION_SCHEMA; Chapter 14: Tools for High Performance; 14.1 Interface Tools; 14.2 Monitoring Tools; 14.3 Analysis Tools; 14.4 MySQL Utilities; 14.5 Sources of Further Information; Transferring Large Files; Copying Files; File Copy Benchmarks; Using EXPLAIN; Invoking EXPLAIN; The Columns in EXPLAIN; Visual EXPLAIN; Using Sphinx with MySQL; Overview: A Typical Sphinx Search; Why Use Sphinx?; Architectural Overview; Special Features; Practical Implementation Examples; Conclusion; Debugging Locks; Lock Waits at the Server Level; Lock Waits in Storage Engines; Colophon;