Notice: Function _load_textdomain_just_in_time was called incorrectly. Translation loading for the pb-seo-friendly-images domain was triggered too early. This is usually an indicator for some code in the plugin or theme running too early. Translations should be loaded at the init action or later. Please see Debugging in WordPress for more information. (This message was added in version 6.7.0.) in /var/www/html/wpxss.com/application/wp-includes/functions.php on line 6260

Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in /var/www/html/wpxss.com/application/wp-content/plugins/wp_glossary/includes/class-wpg-linkify.php on line 316
Save Database Queries for Analysis in WordPress - wpXSS

Deprecated: Function wp_get_loading_attr_default is deprecated since version 6.3.0! Use wp_get_loading_optimization_attributes() instead. in /var/www/html/wpxss.com/application/wp-includes/functions.php on line 6260
wp-config.php » Save Database Queries for Analysis in WordPress

Save Database Queries for Analysis in WordPress


Deprecated: mb_convert_encoding(): Handling HTML entities via mbstring is deprecated; use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead in /var/www/html/wpxss.com/application/wp-content/plugins/wp_glossary/includes/class-wpg-linkify.php on line 316

The SAVEQUERIES wp-config constant saves database queries to an array and We can use that array to display queries. The information saves each query, what function called it, and how long that query took to execute.

To enable SAVEQUERIES add this to the wp-config.php file:

define( 'SAVEQUERIES', true );

Then in the footer of your theme put this:

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

Open your website and in the footer you will notice queries.

2021 12 29 20 27 1024x342 - Save Database Queries for Analysis in WordPress

Note: This will have a performance impact on your site, so make sure to turn this off when you aren’t debugging.

See also  Dumping specific tables using mysqldump or WP-CLI

Was this post helpful?

Leave a Comment

I enjoy constructive responses and professional comments to my posts, and invite anyone to comment or link to my site.

Recommended