Title: Not optimized code
Last modified: August 30, 2016

---

# Not optimized code

 *  [Julian M](https://wordpress.org/support/users/caesarby/)
 * (@caesarby)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/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/](https://wordpress.org/plugins/most-popular-posts-widget-lite/)

Viewing 1 replies (of 1 total)

 *  Plugin Author [Piotr Pesta](https://wordpress.org/support/users/piotr-pesta/)
 * (@piotr-pesta)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/not-optimized-code/#post-6654336)
 * 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.

 * ![](https://ps.w.org/most-popular-posts-widget-lite/assets/icon-256x256.png?rev
   =1161927)
 * [Most Popular Posts Widget](https://wordpress.org/plugins/most-popular-posts-widget-lite/)
 * [Support Threads](https://wordpress.org/support/plugin/most-popular-posts-widget-lite/)
 * [Active Topics](https://wordpress.org/support/plugin/most-popular-posts-widget-lite/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/most-popular-posts-widget-lite/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/most-popular-posts-widget-lite/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Piotr Pesta](https://wordpress.org/support/users/piotr-pesta/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/not-optimized-code/#post-6654336)
 * Status: not resolved