Hi Andrea,
These queries come directly from the domain mapping plugin:
(domain_mapping.php:95)
function maybe_create_db() {
global $wpdb;
get_dm_hash(); // initialise the remote login hash
$wpdb->dmtable = $wpdb->base_prefix . 'domain_mapping';
$wpdb->dmtablelogins = $wpdb->base_prefix . 'domain_mapping_logins';
if ( dm_site_admin() ) {
$created = 0;
if ( $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->dmtable}'") != $wpdb->dmtable ) {
$wpdb->query( "CREATE TABLE IF NOT EXISTS <code>{$wpdb->dmtable}</code> (
<code>id</code> bigint(20) NOT NULL auto_increment,
<code>blog_id</code> bigint(20) NOT NULL,
<code>domain</code> varchar(255) NOT NULL,
<code>active</code> tinyint(4) default '1',
PRIMARY KEY (<code>id</code>),
KEY <code>blog_id</code> (<code>blog_id</code>,<code>domain</code>,<code>active</code>)
);" );
$created = 1;
}
if ( $wpdb->get_var("SHOW TABLES LIKE '{$wpdb->dmtablelogins}'") != $wpdb->dmtablelogins ) {
$wpdb->query( "CREATE TABLE IF NOT EXISTS <code>{$wpdb->dmtablelogins}</code> (
<code>id</code> varchar(32) NOT NULL,
<code>user_id</code> bigint(20) NOT NULL,
<code>blog_id</code> bigint(20) NOT NULL,
<code>t</code> timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (<code>id</code>)
);" );
$created = 1;
}
if ( $created ) {
?> <div id="message" class="updated fade"><p><strong><?php _e( 'Domain mapping database table created.', 'wordpress-mu-domain-mapping' ) ?></strong></p></div> <?php
}
}
}
So everytime somebody goes into the admin, it checks for these tables and creates if non existant… So far while testing these queries have taken up to 13 seconds each.
The function is called from domain_mapping.php:48
Isn’t this ridiculously ineffecient? Especially for large networks. We currently have 11.260 sites, with 18 tables per site.