Support » Plugin: Most Popular Posts Widget » Not optimized code

  • Hi.

    I tried to use your plugin, but it is making a lot of queries to DB and then I refused it.

    You have in the “functions.php” file the code like this:

    for(...) {
    	$wpdb->get_results("SELECT post_title FROM $posts_table WHERE ID = $post_number")
    }

    Why do you making separate sql query in cycle?

    You can make just one query above like this:
    $wpdb->get_results("SELECT post_title FROM $posts_table WHERE ID IN ($postsIds) ")

    One general query to DB is more better than N queries.
    If you have a wish, please fix this trouble and your code.

    https://wordpress.org/plugins/most-popular-posts-widget-lite/

Viewing 1 replies (of 1 total)
  • Plugin Author Piotr Pesta

    (@piotr-pesta)

    Hello,

    thanks for suggestion! Of course you are right about that, I’ll try to decrease number of queries with next update.

    Regards!

Viewing 1 replies (of 1 total)
  • The topic ‘Not optimized code’ is closed to new replies.