2 remarks on “Local Like And Share v1.0.3 – A Little Cleaner And A Little Faster!

  1. 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

    1. Hi wordpdev23,

      Thanks for trying out Local Like And Share.

      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

Leave a Reply

Your email address will not be published. Required fields are marked *