[wp-hackers] State of WP
kmccann at cruciverb.com
Mon Apr 9 20:14:27 GMT 2007
Donncha O Caoimh wrote:
> This has been explained several times on the MU forums, but for a quick
> recap, the simplest way to use multiple databases is by running the
> blog_id through md5 and grabbing the first 3 characters. This gives you
> a possible 4096 databases, so create that number of databases which is
> where we'll store the data for individual blogs.
> We also need a global db for things like wp_blogs, wp_usermeta and other
> "global" tables.
> So, when a query comes in, if it's a global db query then send it there,
> otherwise grab the blog_id from the query, or simply use $wpdb->blogid,
> find the right db and send the query to that db.
It was one of these forum threads that had me confused. Specifically it
was in your mention of having 4,096 databases. But I think I understand
now. You have multiple sites per database, not one database for each
site, which is how we have Drupal set up. And the reason for doing this
is to simply spread the data out. Do I follow? Now, let's say I do that,
how hard will it be to tweak WPMU to do some interesting things like
blog hierarchy (have a table with blog_id and blog_parent_id to
establish relationships and then do fun stuff), permissions inheritance
(if I can admin the company blog I can admin the child department blog),
etc. The need for this kind of thing is why I always thought it would be
optimal to have all data for all blogs in one huge honkin' database.
Could you confirm the purpose of the 4096 databases (sorry, I'm not an
expert at this type of thing).
More information about the wp-hackers