WordPress.org

Ready to get started?Download WordPress

Forums

Debug Queries
[resolved] Need some help reading the mySQL query output (3 posts)

  1. rughooker
    Member
    Posted 2 years ago #

    I installed http://wordpress.org/extend/plugins/debug-queries/. I can now see which queries are causing the load on my site, but how do I trace them back to the WordPress plugin, custom page, widget, etc?

    Here's a few from my home page that take the most time based on the number in Time:

    Time: 6.38961791992E-5
    Query: SELECT post_id, meta_key, meta_value FROM wp_postmeta WHERE post_id IN (4654)
    C
    Time: 7.70092010498E-5
    Query: SELECT <code>post_parent</code> FROM wp_posts WHERE ID = 260 LIMIT 1
    Call from: require, require_once, include, get_header, locate_template, load_template, require_once, wp_head, do_action, call_user_func_array, adjacent_posts_rel_link_wp_head, adj
    Time: 8.48770141602E-5
    Query: SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag', 'post_format') AND tr.object_id IN (4654) ORDER BY t.name ASC
        Call from: require, require_once, include, WP_Query->query, WP_Query->get_posts, update_post_caches, update_object_term_cache, wp_get_object_terms
    Time: 8.60691070557E-5
    Query: SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy = 'category' AND t.term_id = 56 LIMIT 1
    Call from: require, require_once, include, WP_Query->query, WP_Query->get_posts, get_term_by, get_term
    Time: 9.10758972168E-5
    Query: SELECT <code>post_parent</code> FROM wp_posts WHERE ID = 260 LIMIT 1
    Call from: require, require_once, include, get_header, locate_template, load_template, require_once, wp_head, do_action, call_user_func_array, adjacent_posts_rel_link_wp_head, adj
    Time: 9.89437103271E-5
    Query: SELECT <code>post_parent</code> FROM wp_posts WHERE ID = 260 LIMIT 1
    Call from: require, require_once, include, get_header, locate_template, load_template, require_once, wp_head, do_action, call_user_func_array, adjacent_posts_rel_link_wp_head, adjacent_posts_rel_link, get_adjacent_post_rel_link, get_permalink, get_post, _get_post_ancestors

    There are many others, but they all have a time under 0.0
    And this is at the bottom of the page:

    Total query time: 0.04057s for 49 queries.
        Total num_query time: 0.921 for 51 num_queries.
        ยป Different values in num_query and query? - please set the constant define('SAVEQUERIES', true);in your wp-config.php
        Page generated in 0.91223s, 95.55% PHP, 4.45% MySQL

    The plug in support site is not in English. I need some guidance on how to read this output.

    Most of what I read on the internet and slow mySQL queries has to do with adding indexes. I understand indexes somewhat, I used to program in Microsoft Access (Windows 98 era). How does this apply to WordPress?

    I have tried deactivating plugins, changing themes, etc. Nothing has made a significant difference yet.

    Can custom post types affect this? I've added some, but have not implemented showing them on the site yet in any significant way.

  2. rughooker
    Member
    Posted 2 years ago #

    After posting this, I can see that these are probably my fastest queries. I did not notice the E-5 behind the number.

  3. Frank
    Member
    Plugin Author

    Posted 2 years ago #

    A examble:
    Time: 0.00058102607727051
    the period for this query in seconds
    Query: SELECT * FROM wp_users WHERE user_login = 'admin'
    the SQL statement, an Select to all table fields in wp_users, if
    user_login is exact admin
    Call from: require, require_once, require_once, require_once,
    WP->init, wp_get_current_user, get_currentuserinfo,
    wp_validate_auth_cookie, get_userdatabylogin, get_user_by
    this are the functions, class or methods, there call this sql statement. it is an stacktrace (an helper for debugging) and only so it is possible to see, which functions are in the process of this select. All reuires an in the stack.

    Ideas, Requirements for the plugin.
    Current i rewrite also an tool for other content stuff on development
    and debugging:
    please see the dev-version of Debug Objects:
    http://wordpress.org/extend/plugins/debug-objects/download/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic