Support » Plugin: WP-PostRatings » db usage

  • Resolved viliusl

    (@viliusl)


    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

    (@gamerz)

    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

    • This reply was modified 4 years, 3 months ago by Lester Chan.
    Thread Starter viliusl

    (@viliusl)

    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

    (@gamerz)

    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.