• wordpdev23

    (@wordpdev23)


    Hi, great plugin.But activeduty.

    When you create like that is an entry in the mysql table
    1 like – 1 entry

    If the page displays multiple posts, with a large number of like everyone, possibly a large load on the server!

    It would be great if this Bug fix

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Devon Ostendorf

    (@devonostendorf)

    Hi wordpdev23,

    Thanks for trying out Local Like And Share (and for the generous rating). I saw the comment you left on my blog first, and replied to it, so this is effectively a (close to) verbatim duplicate response.

    The reason a SELECT is done for each post displayed on a page is because I made the design decision to prevent (or at least discourage) multiple likes by a single user. You may agree or not with this decision but I felt that if one wanted something even remotely resembling an accurate representation of a “most liked post”, each user should only be allowed to like a post once. In order to do this, you need to track each like, by user (hence what you identified as “1 like – 1 entry” in the SQL table).

    I also wanted to make the user experience a little better by disabling the like button (and accompanying it with a specific message indicating to the user that they’d already liked a particular post), so I incurred the cost of an additional SELECT to see if the current user had previously liked this post. You could certainly change the code to skip this SELECT, meaning a user would ALWAYS be able to click the like button, while the existing AJAX handler code would continue to prevent incrementing the like count for a user that has already liked the current post. I have not personally seen the situation materialize where the cost of this single additional SELECT, per post, outweighs the ability to show the user, immediately on page rendering, that they’ve already liked a post and cannot like it again. But perhaps this will be an issue for those blogs with significantly larger readership (and/or better quality material [equating to considerably large like counts]!) than mine. 🙂

    Since you mentioned posts with large numbers of likes, I’ll note that to calculate the like total, per post, a SQL COUNT() function call is used, and since post_id is a part of the like table’s primary key I do not believe a full table scan is being performed by the COUNT() (at least not in MySQL). I am not a DBA, however, so if you are (or just know more about databases than I do, which is entirely possible), I’d be happy to accept that there may be room-for-improvement, performance-wise, in this area.

    If server load is a real, immediate concern of yours, you can choose to only display likes (and/or shares) on individual posts, for at least an interim solution. I’d be interested to hear what sort of like counts you are talking about here.

    Hope this helps,
    Devon

    Plugin Author Devon Ostendorf

    (@devonostendorf)

    Hi wordpdev23,

    After some further investigation, I confirmed your concern about performance when running the code on a blog with high traffic (and/or correspondingly high numbers of likes and/or shares). Consequently, Local Like And Share version 1.0.5 (released 9/22/2016) aggregates like and share counts in the WP core postmeta table, for display on public-facing pages (while the original custom tables are used for admin statistic views).

    Thanks for raising this issue; I think the plugin, and all of those who use it, will benefit from the improvement that came out of your note!

    Thanks,
    Devon

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Hi, great plugin’ is closed to new replies.