We often encounter customers who have partitioned their applications among a number of databases within the same instance of MySQL (think application service providers who have a separate database per customer organization ... or wordpress-mu type of apps). For example, take the following single MySQL instance with multiple (identical) databases:
SHOW DATABASES; +----------+ | Database | +----------+ | db1 | | db2 | | db3 | | db4 | | mysql | +----------+
Separating the data in this manner is a great setup for being able to scale by simply migrating a subset of the databases to a different physical host when the existing host begins to get overloaded. But MySQL doesn't allow us to examine statistics on a per-database basis.
There is an often-ignored gem in Maatkit's mk-query-digest, and that is the --group-by argument. This can …[Read more]