Databases Reference
In-Depth Information
Storage engines are a great way to extend MySQL for a special purpose. Brian Aker has
written a skeleton storage engine and a series of articles and presentations about how
to get started writing your own storage engine. This has formed the basis for several of
the major third-party storage engines. Many companies have written their own internal
storage engines. For example, some social networking companies use special storage
engines for social graph operations, and we know of a company that built a custom
engine for fuzzy searches. A simple custom storage engine isn't very hard to write.
You can also use a storage engine as an interface to another piece of software. A good
example of this is the Sphinx storage engine, which interfaces with the Sphinx full-text
search software (see Appendix F ).
Alternatives to MySQL
MySQL is not necessarily the solution for every need. It's often much better to do some
work completely outside MySQL, even if MySQL can theoretically do what you want.
One of the most obvious examples is storing data in a traditional filesystem instead of
in tables. Image files are the classic case: you can put them into a BLOB column, but this
is rarely a good idea. 3 The usual practice is to store images or other large binary files
on the filesystem and store the filenames inside MySQL; the application can then re-
trieve the files from outside of MySQL. In a web application, you accomplish this by
putting the filename in the <img> element's src attribute.
Full-text searching is something else that's best handled outside of MySQL—MySQL
doesn't perform these searches as well as Lucene or Sphinx.
The NDB API can also be useful for certain tasks. For instance, although MySQL's
NDB Cluster storage engine isn't (yet) well suited for storing all of a high-performance
web application's data, it's possible to use the NDB API directly for storing website
session data or user registration information. You can learn more about the NDB API
at http://dev.mysql.com/doc/ndbapi/en/index.html . There's also an NDB module for
Apache, mod_ndb , which you can download at http://code.google.com/p/mod-ndb/ .
Finally, for some operations—such as graph relationships and tree traversals—a
relational database just isn't always the right paradigm. MySQL isn't good for dis-
tributed data processing, because it lacks parallel query execution capabilities. You'll
probably want to use other tools for this purpose (possibly in combination with
MySQL). Examples that come to mind:
3. There are advantages to using MySQL replication to distribute images quickly to many machines, and
we know of some applications that use this technique.
 
Search WWH ::




Custom Search