Title: View Page SQL Queries?
Last modified: August 18, 2016

---

# View Page SQL Queries?

 *  [war59312](https://wordpress.org/support/users/war59312/)
 * (@war59312)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/view-page-sql-queries/)
 * Hey,
 * Is there anyway to see what queries are running while a wordpress page loads?
 * Thanks,
 * SQL Newbie 😉

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [19 years, 9 months ago](https://wordpress.org/support/topic/view-page-sql-queries/#post-435940)
 * 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"; print_r($wpdb->queries); 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](https://wordpress.org/support/users/markjaquith/)
 * (@markjaquith)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/view-page-sql-queries/#post-435946)
 * Alternative… and safer:
 * `
    <?php if ( SAVEQUERIES && current_user_can('manage_options') && $_GET['showqueries']){
   echo "<!--n"; print_r($wpdb->queries); echo "n-->n"; } ?>
 * Then just access [http://example.com/?showqueries=1](http://example.com/?showqueries=1)
   while logged in as an Administrator level account.
 *  Thread Starter [war59312](https://wordpress.org/support/users/war59312/)
 * (@war59312)
 * [19 years, 9 months ago](https://wordpress.org/support/topic/view-page-sql-queries/#post-436199)
 * 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.

## Tags

 * [queries](https://wordpress.org/support/topic-tag/queries/)
 * [sql](https://wordpress.org/support/topic-tag/sql/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [war59312](https://wordpress.org/support/users/war59312/)
 * Last activity: [19 years, 9 months ago](https://wordpress.org/support/topic/view-page-sql-queries/#post-436199)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
