ADMIN
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
FeAtures<br />
mysQL Forks and Patches<br />
complete list of patches and notes on<br />
how to use them.<br />
© Dmitry Karasew, 123RF.com<br />
Modern MySQL Forks and Patches<br />
Spoiled for<br />
Choice<br />
mysQL is the standard solution for free relational database systems in web applications,<br />
but new forks, more storage engines, and patched versions muddy the water.<br />
now’s the time to take stock of the most important offerings. By caspar clemens mierau<br />
If your MySQL server is too slow,<br />
you have various approaches to solving<br />
the problem. Besides optimizing<br />
queries and indexes, reworking the<br />
configuration, and upgrading your<br />
hardware, moving to a customized<br />
version of the MySQL server can be<br />
a good idea. In recent years, so many<br />
patches, forks, and new storage engines<br />
have been released that it is<br />
hard to keep track of them. For hardworking<br />
developers and database<br />
administrators, this means a change<br />
from the simple choice of a standard<br />
MySQL distribution.<br />
Little Band-aids<br />
Many enhancements for MySQL come<br />
from major corporations like Facebook<br />
[1] and Google [2], who run<br />
their ad services on top of MySQL<br />
or from MySQL specialists like Per-<br />
cona [3], whose claim to fame is<br />
the “MySQL Performance Blog” [4]<br />
(standard reading for anyone interested<br />
in MySQL). The patches can be<br />
grouped into three categories: (1) reporting<br />
enhancements, (2) functional<br />
enhancements of the MySQL kernel<br />
and database engines, and (3) performance<br />
optimizations. In most cases, a<br />
combination of patches from all three<br />
categories will make the most sense.<br />
Moving to a database server that you<br />
patched and compiled yourself can<br />
be a daunting prospect. Thankfully,<br />
projects such as OurDelta [5] offer repositories<br />
with meaningfully patched<br />
and prebuilt MySQL packages for<br />
popular distributions like Debian,<br />
Ubuntu, and CentOS/ RHEL. The<br />
patches I will be looking at in the rest<br />
of this article are a cross-section of<br />
the current OurDelta versions of the<br />
MySQL server; see their website for a<br />
Reporting<br />
Extended reporting allows administrators<br />
to collect more granular information<br />
about the MySQL server’s<br />
behavior under load. Thus far, slow.<br />
log, which offers very little in the<br />
line of configuration options, might<br />
be your first port of call. However, its<br />
utility value is restricted to identifying<br />
individual, computationally intensive<br />
queries on the basis of the time they<br />
use – and non-used indexes. The<br />
MicroSlow patch offers new filters<br />
for a more targeted search for poorly<br />
formulated queries. Thus, it logs queries<br />
that are responsible for writing<br />
temporary tables to disk, performing<br />
complete table scans, or reading a<br />
freely defined minimum number of<br />
lines in a table. The mysqldumpslow<br />
Slow.log statistics tool, which is not<br />
very well known but is part of the<br />
MySQL standard distribution, has<br />
been modified to be able to read and<br />
evaluate the extended entries.<br />
Aggregated run-time statistics on usage<br />
behavior are equally as useful.<br />
The UserStats patch extends MySQL<br />
by adding statistics for users, clients,<br />
tables, and indexes. After enabling<br />
data collection in my.cnf or issuing<br />
the SQL SET GLOBAL userstat_running<br />
= 1 command at run time, four tables<br />
in the information_schema, USER_STA‐<br />
TISTICS, CLIENT_STATISTICS, INDEX_<br />
STATISTICS, and TABLE_STATISTICS,<br />
are continually populated with data.<br />
The statistics can be accessed via the<br />
SHOW command. For example, SHOW<br />
TABLE_STATISTICS will give you a<br />
table-by-table evaluation of lines read<br />
and modified and indexes updated.<br />
Direct access to the statistics tables in<br />
information_schema is useful because<br />
they are accessed as normal tables,<br />
and you can target the results to<br />
manipulate. Listing 1 shows a query<br />
for the five tables with the most<br />
frequently read lines. This example<br />
taken from Live operations of the<br />
Rails-based Moviepilot movie community<br />
and the underlying movie database<br />
OMDB (both anonymized for<br />
20 Admin 01 www.Admin-mAgAzine.com