Improve speed for cpto_get_previous_post_where
-
Hi, may I suggest a possible improvement for your plugin.
In cpto_get_previous_post_where and cpto_get_next_post_where (include/class.functions.php).
Code doing the prepare SELECT could be improve by using
SELECT p.id
INSTEAD ofSELECT p.*
and by adding
LIMIT 1
after the$_where
.SUGGESTED:
$query = $wpdb->prepare( "SELECT p.id FROM $wpdb->posts AS p $_join WHERE p.post_date > %s AND p.menu_order = %d AND p.post_type = %s AND p.post_status = 'publish' $_where LIMIT 1", $post->post_date, $current_menu_order, $post->post_type );
It could also be a SELECT count(p.id) as mycount with a get_var, but that need more rework.
All of this, to remove the extra time to get all results from the database into PHP without reason. I saw the request fetching 4000 rows on a website, and still increasing, just to check for (count($results) > 0).
Thanks for your time.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Improve speed for cpto_get_previous_post_where’ is closed to new replies.