Support » Fixing WordPress » View Page SQL Queries?

  • Hey,

    Is there anyway to see what queries are running while a wordpress page loads?


    SQL Newbie 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    If you know a little PHP, yes.

    Add this to your wp-config file:
    define('SAVEQUERIES', true);

    Then, somewhere in your template (probably at the end of the footer.php, add this code:
    if (SAVEQUERIES) {
    echo "<!--\n";
    echo "\n-->\n";

    I think that will do it. Anyway, then look at the source of any page and all the queries it ran will be at the bottom.

    Don’t leave this turned on, BTW. Turn it off again when you’re done looking at the output.

    Mark Jaquith


    WordPress Lead Dev

    Alternative… and safer:

    if ( SAVEQUERIES && current_user_can('manage_options') && $_GET['showqueries'] ) {
    echo "<!--n";
    echo "n-->n";

    Then just access while logged in as an Administrator level account.

    Sweet! Thanks to both of you! 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘View Page SQL Queries?’ is closed to new replies.