Title: db usage
Last modified: July 18, 2017

---

# db usage

 *  Resolved [viliusl](https://wordpress.org/support/users/viliusl/)
 * (@viliusl)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/db-usage/)
 * Code below is executing on every post save, and so database is filled with lots
   of zeroes. If there are many post ( >10 000), it slows down wp-admin, because
   about 25% of database fields are these ‘0’ values. Fix is to remove this code.
 * >  add_post_meta($post_ID, ‘ratings_users’, 0, true);
   >  add_post_meta($post_ID,‘
   > ratings_score’, 0, true); add_post_meta($post_ID, ‘ratings_average’, 0, true);

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/db-usage/#post-9329611)
 * It needs the 0, if not if you do a WP Query to get the most rated/posts, those
   without 0 will not show up.
 * If you dig into the WP code, it will not be added if the post already contains
   the post_meta. See [https://codex.wordpress.org/Function_Reference/add_post_meta](https://codex.wordpress.org/Function_Reference/add_post_meta)
    -  This reply was modified 8 years, 10 months ago by [Lester Chan](https://wordpress.org/support/users/gamerz/).
 *  Thread Starter [viliusl](https://wordpress.org/support/users/viliusl/)
 * (@viliusl)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/db-usage/#post-9332257)
 * I don’t think that topic is resolved.
 * 1. even there are no duplicates, it creates 3 empty values for each posts. It
   increase db size and db query times, and page load times.
    2. why you need posts
   without ratings to appear in most rated lists? 3. don’t be lazy to optimize/fix
   code.
 * Some statistics: wp-admin load time with fix above will load 25% faster. Tested
   on real site with many posts.
 *  Plugin Author [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * (@gamerz)
 * [8 years, 10 months ago](https://wordpress.org/support/topic/db-usage/#post-9332341)
 * 1, 2) I have requests for posts without ratings to appear many times.
    3) See
   above. I am ok removing it and removing is so easy. But it will be a vicious 
   circle as I will get support questions for posts not appearing in the list with
   0 votes.
 * As of now, I will make the decision to include those fields, if my plugins don’t
   fit your needs, feel free to fork it and remove those 3 fields for your needs.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘db usage’ is closed to new replies.

 * ![](https://ps.w.org/wp-postratings/assets/icon.svg?rev=978014)
 * [WP-PostRatings](https://wordpress.org/plugins/wp-postratings/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-postratings/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-postratings/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-postratings/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-postratings/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-postratings/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Lester Chan](https://wordpress.org/support/users/gamerz/)
 * Last activity: [8 years, 10 months ago](https://wordpress.org/support/topic/db-usage/#post-9332341)
 * Status: resolved