[HyperDB] Partitioning wpmu data

Andy Skelton skeltoac at gmail.com
Thu Apr 23 17:49:37 GMT 2009


> So, we need to scale somehow. That¹s why he have looked at HyperDB, which
> seems to have been built just for that.

Exactly right. WordPress.com, a WordPress MU installation with
millions of blogs, uses HyperDB. Rather, HyperDB is based on the
WordPress.com database class. We have additional logic to map blogs
onto database partitions.

Inspect get_dataset_from_table. You can add your own logic there or in
db_connect, or just take advantage of the pattern matching.

I am reluctant to write documentation for HyperDB because I wouldn't
advise its use to anyone who wasn't thoroughly familiar with how it
works. The code isn't the prettiest, but it can be understood.

How you organize your tables is entirely up to you. WordPress.com blog
tables were originally mapped to a set of 4096 databases (wpmu_000 -
wpmu_fff) by taking the first three hex digits of the md5 of the
blog_id. A million blogs later, we added a column to wp_blogs to store
the partition that held the blog's tables so that we could move them
around without losing them.

That's about all the help I can provide you. Anyone else who is
familiar with HyperDB may chime in. My usual advice applies: study the
code.

Cheers,
Andy


More information about the HyperDB mailing list