High Performance MySQL

highperformancemysql.jpg

Title: High Performance MySQL

Author: Jeremy Zawodny, Derek Balling

Summary: A great book for those looking to scale with MySQL

I had the pleasure of being one of the technical reviewers of the book, and seeing the book is now available it’s probably a good time to give my opinion on their work.

This book is aimed at the MySQL developer/administrator who has a server in place and now needs to start squeezing more performance out of it. I would say this is a pretty common demographic and the book addresses this group extremely well. I wish I had a copy of this book when I got into that phase, and even now I find myself pulling out my copy to look up some of the good tips and tricks that fill this book.

The ordering of the chapters is effective and leads the user through the stages of tweaking a server. This book does not really cover the absolute basics such as SELECT syntax, which suits me just fine.

The authors start out with a very in-depth discussion of table-types. They not only give the features of each table type, they also discuss the benefits and tradeoffs involved in choosing among the various table types. Transactions are covered in detail, including a rundown of the different isolation levels and how to choose the best isolation level for your application. I particularly liked that the table type choices were discussed in terms of scenarios that the reader may encounter, such as logging, catalogs, and even CD-ROM based content.

The authors wisely put a chapter on benchmarking right at the start of the book. Without having some idea of proper benchmarking techniques it can be very difficult to determine what changes benefit your servers performance. This book covers not only benchmarking methodology but also some of the more common benchmarking tools available to a MySQL administrator.

Indexing is one of the first and more effective ways to improve query performance, and the authors cover the subject quite well. Not only are typical indexing techniques covered, but there are also great explanations of how things work “under the hood”. We learn of the various indexing methods in use with the server, such as B-TREEs, Hash tables, and clustered indexes.

Now that the reader has a firm grasp on how indexing works and how to benchmark queries, the authors introduce us to the concept of query analysis. The authors explain how the MySQL query optimizer works to execute a query and then give an extensive discussion of using the EXPLAIN system and how to use it to determine whether your queries are fully optimized. Advice is given on various ways to improve query performance, including use of the query cache.

Of particular interest to me was chapter 6: Server Performance. This chapter covers everything from choosing memory to selecting a file system for your database server. There is good advice on selecting disks and choosing RAID systems. The chapter also does a great job of covering how to identify and deal with bottlenecks, whether at the CPU, file, or kernel levels. This chapter is a must-read for anyone looking at purchasing a new machine to host a MySQL database, as it gives excellent tips regarding what choices you need to make when choosing server components.

Jeremy Zawodny knows replication. Through his work at Yahoo he has been of MySQL AB’s largest users of replication, and his feedback to the MySQL development team has made it’s way into the end product we currently use in MySQL 4.1. This degree of experience is obvious in chapter 7: Replication. There is great coverage of the steps needed to create a replication scheme, and there is a great discussion of the different replication layouts available to you when configuring multiple servers in a replication scheme. In addition to providing excellent coverage of setting up replication, there is also great coverage of monitoring and troubleshooting replication.

Chapter 8 takes replication a step further by introducing the concept of load balancing and high availability. A thorough discussion of load balancing is given and various high-availability solutions are discussed. The authors provide great coverage of load-balancing concepts and cover some of the pitfalls you may encounter if you are only accustomed to HTTP load balancing (which can vary greatly from MySQL load balancing).

If you pick this book up off the shelf at a bookstore but can’t afford to buy it, make sure you read chapter 9. A DBA’s most vital task is performing backups and other disaster prevention tasks. Chapter 9 covers all the standard backup tools available with MySQL, and also gives great coverage of how you can roll your own backup solution.

The main body of the book is rounded out with chapter 10: Security. The security chapter covers not only the basics of MySQL authentication, it covers some advanced scenarios and helps the reader understand the internal workings of MySQL authentication mechanisms. In addition to covering MySQL security mechanisms, the chapter goes on to discuss operating system security and security concepts such as data encryption. A brief tutorial is even given for setting a MySQL server up in a chroot environment for increased security.

Conclusion

All in all I thought this book was excellent. Windows users with very little background in Linux or other UNIX-like operating systems may encounter unfamiliar terms and sections that are not relevant (for example, the mytop utility covered in Appendix B is not available for Windows), but Windows users should still get a lot out of this book (besides, if you need high-performance from MySQL you should not be using Windows as your base OS). I found the book to be an excellent read and highly recommend it.

And finally, I I had no problem with Zawodny & Balling not pointing out MySQL’s limitations: This book is for existing MySQL Administrators, who will already be aware of it’s limitations. In addition, the features mentioned are already available in MySQL 4 and/or 5, available for download from the MySQL web site.

Leave a Reply