Created
June 27, 2017 15:46
-
-
Save kingkool68/668608121b98118665ede338037329a6 to your computer and use it in GitHub Desktop.
Prevent MySQL from caching database queries when debugging database performance issues.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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; | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helpful in conjunction with a plugin like the Debug bar