• I found that five Participants Database queries are executed on every page of my web site. Although they do not individually take a lot of time, I wonder if for overall performance it would be better (and possible) to do these only on Participants Database admin pages and the pages that include Participants Database shortcodes.

    Thanks
    _______________

    To gather information in an attempt to optimize database performance, I temporarily added the following to my theme’s footer.php. See https://kinsta.com/blog/wp-query/.

    <?php if ( current_user_can( 'administrator' ) ) {
    	global $wpdb;
    	echo '<pre>';
    	print_r( $wpdb->queries );
    	echo '</pre>';
    }?>

    _____________________________________________________________________________________

    The queries that access the Participants Database MySQL tables on every page:

    [8] => Array
    (
    [0] =>
    SELECT v.name, v.title
    FROM wp_participants_database_fields v
    INNER JOIN wp_participants_database_groups g
    ON v.group = g.name
    WHERE v.form_element NOT IN (“rich-text”, “multi-checkbox”,”multi-dropdown”,”multi-select-other”, “link”, “image-upload”, “file-upload”, “password”, “placeholder”, “timestamp”)
    ORDER BY g.order, v.order
    [1] => 0.001410961151123
    [2] => require(‘C:\wamp\www\eltownhall.com\wp-blog-header.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-load.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-config.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, Participants_Db::init, PDb_Settings->__construct, xnau_Plugin_Settings->__construct, PDb_Settings->_define_settings, PDb_Settings::_get_identifier_columns
    )

    [9] => Array
    (
    [0] => SELECT v.*, g.order FROM wp_participants_database_fields v INNER JOIN wp_participants_database_groups g ON v.group = g.name ORDER BY g.order, v.order
    [1] => 0.0018548965454102
    [2] => require(‘C:\wamp\www\eltownhall.com\wp-blog-header.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-load.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-config.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, Participants_Db::init, PDb_Settings->__construct, xnau_Plugin_Settings->__construct, PDb_Settings->_define_settings, PDb_Settings->_get_display_columns, Participants_Db::get_column_atts
    )

    [10] => Array
    (
    [0] => SELECT v.*, g.order FROM wp_participants_database_fields v INNER JOIN wp_participants_database_groups g ON v.group = g.name WHERE v.sortable = 1 AND v.form_element <> “placeholder” ORDER BY g.order, v.order
    [1] => 0.0015819072723389
    [2] => require(‘C:\wamp\www\eltownhall.com\wp-blog-header.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-load.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-config.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, Participants_Db::init, PDb_Settings->__construct, xnau_Plugin_Settings->__construct, PDb_Settings->_define_settings, PDb_Settings->_get_sort_columns, Participants_Db::get_column_atts
    )

    [11] => Array
    (
    [0] => SELECT v.*, g.order FROM wp_participants_database_fields v INNER JOIN wp_participants_database_groups g ON v.group = g.name WHERE v.sortable = 1 AND v.form_element <> “placeholder” ORDER BY g.order, v.order
    [1] => 0.0011000633239746
    [2] => require(‘C:\wamp\www\eltownhall.com\wp-blog-header.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-load.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-config.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, Participants_Db::init, PDb_Settings->__construct, xnau_Plugin_Settings->__construct, PDb_Settings->_define_settings, PDb_Settings->_get_sort_columns, Participants_Db::get_column_atts
    )

    [12] => Array
    (
    [0] => SELECT v.*
    FROM wp_participants_database_fields v
    ORDER BY v.order
    [1] => 0.0010349750518799
    [2] => require(‘C:\wamp\www\eltownhall.com\wp-blog-header.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-load.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-config.php’), require_once(‘C:\wamp\www\eltownhall.com\wp-settings.php’), do_action(‘plugins_loaded’), WP_Hook->do_action, WP_Hook->apply_filters, Participants_Db::init, Participants_Db::_setup_columns
    )

Viewing 1 replies (of 1 total)
  • Plugin Author Roland Barker

    (@xnau)

    Thanks for this, these are good suggestions, I’ve added them to the list to be addressed in an update to be released soon.

    Part of the issue, technically, with preventing queries from getting run on every page is that Participants Database is a shortcode-based plugin. This means that the plugin doesn’t know if it is getting used on a page until it can inspect the content of that page. If you know about the WordPress load cycle, this isn’t available until relatively late in the process, so in some cases it is necessary to set things up and run queries even though they won’t be getting used. We try to do this as efficiently as we can, but improvement is always possible. I really appreciate your help on this.

Viewing 1 replies (of 1 total)

The topic ‘Participants Database – Database Optimization Opportunity’ is closed to new replies.