[HyperDB] testing hyperdb

Andy Skelton skeltoac at gmail.com
Sun Jul 10 03:09:08 UTC 2011


On Sat, Jul 9, 2011 at 8:27 PM, Pkale Robinson <pkale.robinson at gmail.com> wrote:
> I have set up a WP site with one master and two slave dbs. The master is set
> to write, while the slaves are to read. Is there a method for testing,, or
> debuging this set up ?

You can install a callback that receives $query, $elapsed, $backtrace,
and &$wpdb after every query. On WordPress.com we do this:

$wpdb->save_queries = true;
$wpdb->save_query_callback = 'wpcom_save_query_callback';

function wpcom_save_query_callback($query, $elapsed, $backtrace, &$wpdb) {
    // Here you can log stuff like:
    //   $query
    //   $wpdb->dbhname
    //   $wpdb->dataset
    //   $wpdb->last_connection
}

Andy


More information about the HyperDB mailing list