Created
October 7, 2013 15:59
-
-
Save mattheu/6870307 to your computer and use it in GitHub Desktop.
Benchmark update_meta_cache SQL query with and without ORDER BY $id_colurmn param
This file contains 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 | |
// Use this to create a load of meta entries to check its still OK when there are loads of meta entries. | |
// for ( $i = 0; $i < 500; $i++ ) { | |
// $id = 'test-' . uniqid(); | |
// add_post_meta( 1, $id, rand() ); | |
// } | |
// die(); | |
global $wpdb; | |
$query = "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN (1)"; | |
wp_cache_flush(); | |
$start = microtime(true); | |
for ( $i = 0; $i < 1000; $i++ ) { | |
$results = $wpdb->flush(); | |
$results = $wpdb->get_results( $query ); | |
} | |
$end = microtime(true); | |
hm( round( $end - $start, 3 ) ); | |
$query = "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE post_id IN (1) ORDER BY meta_id"; | |
wp_cache_flush(); | |
$start = microtime(true); | |
for ( $i = 0; $i < 1000; $i++ ) { | |
$results = $wpdb->flush(); | |
$results = $wpdb->get_results( $query ); | |
} | |
$end = microtime(true); | |
hm( round( $end - $start, 3 ) ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment