More optimization for comment relish plugin


Thanks for visiting! If you're new here, you may want to subscribe to my RSS feed. This blog posts regular information about web development, unix/linux, How-tos and patches. Go ahead, subscribe to my feed! You can also receive updates via email, instant messenger, skype or tweeter.

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:

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

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Reddit
  • del.icio.us
  • Slashdot
  • Spurl
  • StumbleUpon
  • Furl
  • DZone
  • Netscape
  • NewsVine
  • Technorati
  • YahooMyWeb
  • Simpy
If you enjoyed this post, you should subscribe to my full RSS Feeds

RSS feed | Trackback URI

25 Comments »

collapse thread Comment by Blogging Experiment
2007-07-17 23:02:39

Thank you VERY MUCH! I was going nuts!

 
collapse thread Comment by webd360
2007-07-18 16:02:15

Thanks for creating this, I’ve been waiting for this :)

 
collapse thread Comment by Rhys
2007-07-18 20:35:18

I’m assuming with the two pingbacks that pingbacks work fine with this plugin (unless you haven’t installed it here) ;)

 
collapse thread Comment by Mihai
2007-07-18 20:50:25

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

 
collapse thread Comment by Rhys
2007-07-18 21:48:12

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!

 
collapse thread Comment by Roel
2007-07-28 20:23:53

Love the plugin. Now I just need to create an interesting message ;-)

 
collapse thread Comment by MichelleVan Subscribed to comments via email
2007-08-01 17:34:47

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!

 
collapse thread Comment by Mihai
2007-08-01 19:18:00

What error are you getting exactly ?

 
collapse thread Comment by Ozh
2007-08-21 19:17:17

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.

collapse thread Comment by Mihai
2007-08-21 19:48:23

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.

 
 
collapse thread Comment by Ozh
2007-08-21 19:19:46

your blog ate my comment :/ (contained some other stuff to fix)

collapse thread Comment by Mihai
2007-08-21 19:50:04

nope, I just have to approve new comentators

 
 
collapse thread Comment by Mike
2008-01-16 23:28:43

Comment Relish was working great, until today when it crashed my blog when I accidentally made a trackback from one post to another.

 
collapse thread Comment by Norman
2008-02-26 15:43:15

I’m assuming with the two pingbacks that pingbacks work fine with this plugin (unless you haven’t installed it here) ;)

 
collapse thread Comment by Krzysztof Lis Subscribed to comments via email
2008-03-26 17:25:59

Everything’s cool, but your plugin doesn’t support any letters from non-english charset. :(

 
collapse thread Comment by Mihai
2008-03-26 17:43:36

Well it’s not my plugin. I just fixed one issue with it.

 
collapse thread Comment by Krzysztof Lis Subscribed to comments via email
2008-03-26 18:12:19

So what stops you from adding some features?

 
collapse thread Comment by Mihai
2008-03-26 18:22:34

mostly lack of free time

 
collapse thread Comment by Zac Subscribed to comments via email
2008-06-25 04:29:39

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

 
Name (required)
E-mail (required - never shown publicly)
URI
Subscribe to comments via email
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

Trackback responses to this post


Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 License

Technology Blogs - Blog Top Sites Search For Blogs, Submit Blogs, The Ultimate Blog Directory Blogarama - The Blog Directory 5starsblog Computers Blogs - Blog Flare blog search directory gob BlogHop