Select the Trace 'shutdown' saved queries
checkbox to obtain a summary of the queries performed during the transaction.
The output is produced in two trace records.
- The WPDB global object – providing all the details.
- Summarised using [bw_sql] shortcodes.
Example
C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\oik-actions.php(153:0) bw_trace_saved_queries(1) 39 2 2019-12-04T16:26:33+00:00 0.306400 0.016622 cf=shutdown 52 3912 6291456/6291456 256M F=600 saved queries wpdb Object ( [show_errors] => 1 [suppress_errors] => [last_error] => [num_queries] => 52 [num_rows] => 1 [rows_affected] => 0 [insert_id] => 0 [last_query] => SELECT comment_approved, COUNT( * ) AS total FROM wp_comments GROUP BY comment_approved [last_result] => Array ( [0] => stdClass Object ( [comment_approved] => 1 [total] => 52 ) )
and
C:\apache\htdocs\wordpress\wp-content\plugins\oik-bwtrace\includes\oik-actions.php(156:0) bw_trace_saved_queries(2) 40 2 2019-12-04T16:26:33+00:00 0.307534 0.001134 cf=shutdown 52 3912 6291456/6291456 256M F=600 Queries: 52 in 0.043546438217163 <h3>Queries</h3> [bw_sql 1 0.000951 get_option]SELECT option_value FROM wp_options WHERE option_name = 'uninstall_plugins' LIMIT 1[/bw_sql] [bw_sql 2 0.001354 WP_User::get_data_by]SELECT * FROM wp_users WHERE user_login = 'wp' LIMIT 1[/bw_sql] [bw_sql 3 0.001507 update_meta_cache]SELECT user_id, meta_key, meta_value FROM wp_usermeta WHERE user_id IN (1) ORDER BY umeta_id ASC[/bw_sql]
Notes
- In my experience the elapsed time of the SQL queries hardly ever reveals a performance problem with data access.
- When this option is selected the Daily Trace Summary report will show the Query time.
- See bw_trace_saved_queries().