High database load from Ajax Edit Comments…

… and a preliminary solution:

The WordPress plugin “Ajax Edit Comments” from The Reader Appreciation Project1 allows the commenter to edit his comment for a certain time – useful especially for typos and minor corrections. (Admins can do more.) Visitors utilize it here for about every 10th comment, by the way.

Now Pierre notified me yesterday about the high number of database queries (and that the response time could be better, too) – higher than what I always saw when logged in. (See the blue footer line.) Doing a little research, I found that it’s the aforementioned Ajax Edit Comments that uses 4 additional database queries for each comment in order to check if the visitor is allowed to edit it (unles (s)he’s logged in as admin who is always allowed to edit). That can sum up to quite a lot if there are many comments on a single post.

I quickly added a little modification to the plugin2 which check the comment age in advance without database access – in my quick tests, these modifications appear to work fine. If you too don’t see any problems – feel free to test it here or maybe later for the music quiz on 16:00 – I will, of course, send the changes to the plugin’s author, hoping they will be included in future versions. :)

  1. for WordPress 2.5 and higher – old version for 2.1–2.3.x here []
  2. in both the old version I’m still using here and the new in my test environment where I’m preparing the WordPress 2.7 update []

20 Comments

  1. PM

    Hey, da hast Du ja schnell ne Lösung gefunden. Leider habe ich heute zum Musik-Quiz wieder keine Zeit :-(

  2. S

    sexy Symbolfoto :mrgreen: herrlich

  3. c

    Würde mich mal interessieren, was die weiblichen Leser dazu sagen. :)

    Pierre, tja, schade mit dem Quiz – und jetzt ist es auch schon wieder vorbei…

  4. M

    Hola die Waldfee, ich dachte mir gerade warum das bei mir nicht so ist, dabei war ich ja als Admin eingeloggt… 442 Queries bei 96 Kommentaren. Gute Nacht.

  5. c

    Solang’s der Server aushält… :|

    Sofern der Plugin-Autor keine Nebenwirkungen meiner Änderungen findet (so wahnsinnig übersichtlich ist der Code nicht), dürfte er sie ja bald einbauen – andernfalls (bzw. auch jetzt schon) kann ich ja selber meine Version zur Verfügung stellen.

  6. M

    Och, jetzt liefs schon so lange, jetzt kann ich auch auf das offizielle Update warten! Aber lobend erwähnen werd ich, wenns soweit ist. :)

  7. M

    Hat dir der Autor verraten, wann er das Update plant?

  8. c

    Er hatte nur (kurz nach meiner Mail) gesagt, er würde sich drum kümmern – mehr/genaueres hab ich seitdem nicht von ihm gehört.

  9. M

    Stell doch mal deine Version zur Verfügung, das dauert mir beim Autor zu lange. :)

  10. M

    Danke!

  11. M

    Fein, von 500 auf 60 Queries nenne ich mal einen signifikanten Abstieg.

  12. M

    Gerade hab ich auf die neuste Version aktualisiert und dein Patch wurde immer noch nicht integriert!

Leave a Reply to Michael

All inputs are optional. The e-mail address won't be published nor shared.

  • Moderation: Comments from first-time commentators must be approved manually before they appear.
  • Behave yourself! No insults, no illegal content, etc.! Should go without saying, don't you agree...?
  • Website: I don't mind blogs with ads, but purely commercial links are not welcome and will be deleted. Just like pure spam comments.
  • Allowed HTML tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <sub> <sup> <big> <small> <u>