More optimization for comment relish plugin
In my previous post about optimizing the comment relish plugin I managed to lower the load generated by the comment relish plugin on the database server by adding an index on a column in the cr_emailed table and by optimizing a query ( basically removing a "useless?" join ). This improved the load time a lot but some users still reported slow load times on blogs with a lot of comments.
Looking more over the source code I realized that the function that tried to find new commentators was executed on each page. This function was executing a mysql query that joined two tables wp_comments and wp_cr_emailed. I think you can imagine the result of this on blogs with a large number of comments.
The solution was to execute this function only when a new comment was posted. And this comes with two benefits:
- because this is called only when a new comment is posted ( or approved ) the rest of the blog will remain as fast as before the plugin was installed.
- because of the way we call the function ( as an action/hook associated with the code that processes the comments ) we have more information about the comment so we don't have to do the query where we join two tables. We still do one query to get the whole comment data and one to see if this is a new commentator ( not emailed yet ) but these use indexes and are really fast.
Get the new optimized plugin here and let me know how it works for you.
Update:
the plugin link above contains a plugin that tries to send email even when the blog receives a pingback or trackback as reported by Rhys. I have uploaded another version that corrects this problem here: http://patchlog.com/wp-content/plugins/comment-relish.new.3.zip
If you enjoyed this post, you should subscribe to my full RSS Feeds












Thank you VERY MUCH! I was going nuts!
Thanks for creating this, I’ve been waiting for this
I’m assuming with the two pingbacks that pingbacks work fine with this plugin (unless you haven’t installed it here)
Actually I had the older version installed here, the one I presented in this post:
http://patchlog.com/wordpress/comment-relish-optimization/ and I didn’t notice this problem.
Anyway here’s an update that does not try to send an email to pingbacks and trackbacks http://patchlog.com/wp-content/plugins/comment-relish.new.3.zip
Thank you for this, I guess I should’ve explained myself better.
On my old theme, and the old version of comment relish, for reasons you identified in that post, my blog would crash if somebody sent me a trackback. As a result, I managed to edit it so that trackbacks didn’t activate the code like comments did.
Excellent work by the way!
Love the plugin. Now I just need to create an interesting message
I’m still getting the error and can’t seem to fix it. I downloaded the new one, delete the old one - do I need to reinstall and deactivate first? help!
What error are you getting exactly ?
Very nice patch (and much needed, jeez, looking for new commenters on each page load?? silliest stuff ever)
A few more stuff to fix for you!
- It still misses some stripslashes (on line 288 and when outputting the options in the admin page, otherwise you see plenty of “I\’m happy you\’ve left a comment”
- it’s full of PHP short tags (<? instead of <?php) which will make the plugin break everything on purist setups.
Thanks for the suggestions. I will release another patch that fixes the stripslashes thing. As for the short tags, I never encountered such a problem.
your blog ate my comment :/ (contained some other stuff to fix)
nope, I just have to approve new comentators
Comment Relish was working great, until today when it crashed my blog when I accidentally made a trackback from one post to another.
I’m assuming with the two pingbacks that pingbacks work fine with this plugin (unless you haven’t installed it here)
Everything’s cool, but your plugin doesn’t support any letters from non-english charset.
Well it’s not my plugin. I just fixed one issue with it.
So what stops you from adding some features?
mostly lack of free time
So installed v3 on a test instance of my site and left 4 comments. I got 4 welcome messages - anyone experienced this as well?
cheers,
Zac