[wp-hackers] Caching of numbers of comments?

Ryan Boren ryan at boren.nu
Thu Dec 22 20:40:17 GMT 2005


On Thu, 2005-12-22 at 19:16 +0100, Sebastian Herp wrote:
> Peter Westwood wrote:
> 
> >On Thu, December 22, 2005 1:25 pm, Sebastian Herp wrote:
> >  
> >
> >>Hello list,
> >>
> >>wordpress 2.0 RC3 seems to cache a lot of things. Does it cache the
> >>number of comments returned by the "comments_number"-function? Because
> >>that number seems to be displayed wrong in several postings. Why exactly
> >>does this need caching or is this bug not related to the cache?
> >>
> >>Example:
> >>http://www.sebbi.de/archives/2005/12/21/premiere-weg-vom-fenster/
> >>The function currently returns "5 comments" while I definetly see 6 ...
> >>
> >>    
> >>
> >
> >Comment Count is stored in the db against each post to save on queries for
> >the front page. (New in 2.0)
> >
> >I suspect you are running a comment processing plugin that die()'s inside
> >the hook like Spam Karma 2 does (The fix for which is here -
> >http://lair.fierydragon.org/2005/11/sk2-wp2compatibility/)
> >
> >westi
> >  
> >
> Aha! That's exactly what is causing the problem. Thank you! Introducing 
> redundancy at this point is however the baddest idea I've ever seen. Why 
> would someone "copy" a simple number just to save one simple query that 
> uses less than one tenth of a millisecond to execute? A query, btw, that 
> could have been easily "joined" to the main-query which gets the posts 
> ... redundancy in a database scheme is a very very very (I can't say it 
> often enough) bad thing ...


COUNT() is very slow with InnoDB.

Ryan



More information about the wp-hackers mailing list