Repository navigation
Need help with Partitioning config #162
|
Hi there, I'm try to setup db partitioning for multisite with 15 child sites. Currently I'm config as
How can I do that? Thanks for your help, |
Replies: 2 comments
|
even i would like to know if there is a solution |
|
Yes. Route on the numeric blog ID parsed from $wpdb->add_callback(
function ( $query, $wpdb ) {
$pattern = '/^' . preg_quote( $wpdb->base_prefix, '/' ) . '(\d+)_/';
if ( ! preg_match( $pattern, $wpdb->table, $matches ) ) {
return null;
}
$blog_id = (int) $matches[1];
if ( $blog_id >= 2 && $blog_id <= 5 ) {
return 'child_db_2_5';
}
if ( $blog_id <= 10 ) {
return 'child_db_6_10';
}
if ( $blog_id <= 15 ) {
return 'child_db_11_15';
}
return null;
}
);Add each returned dataset with The same approach is now documented in the wiki's Partitioning Recipes page. |
Yes. Route on the numeric blog ID parsed from
$wpdb->table, and return the dataset for the matching range:Add each returned dataset with
$wpdb->add_database()first. The site's tables must already exist in that physical database, and related tables…