Skip to content

Instantly share code, notes, and snippets.

@kingkool68
Created June 27, 2017 15:46
Show Gist options
  • Select an option

  • Save kingkool68/668608121b98118665ede338037329a6 to your computer and use it in GitHub Desktop.

Select an option

Save kingkool68/668608121b98118665ede338037329a6 to your computer and use it in GitHub Desktop.
Prevent MySQL from caching database queries when debugging database performance issues.
<?php
// Force MySQL to not cache queries. Helpful for database performance testing.
// DO NOT LEAVE THIS ON IN PRODUCTION!
add_filter( 'query', function( $query ) {
$query = preg_replace( '/SELECT /', 'SELECT SQL_NO_CACHE ', $query, 1 );
return $query;
});
@kingkool68

Copy link
Copy Markdown
Author

Helpful in conjunction with a plugin like the Debug bar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment