tags: WordPress
Turbocharging StatTraq
April 22nd, 2005, by Rich.
If you use StatTraq and WordPress, or if you use any kind of open-source statistics package on your website, you may benefit from this. Whilst reading around the intricacies of MySQL yesterday I discovered something so blindingly obvious that I think there must be a conspiracy to not talk about it.
To my surprise it appears that by adding a solitary word to my StatTraq installation I have managed to remove ninety-something percent of the time it was adding to my page views.
Previously, every time somebody looked at a page on my site the server would write an entry to the database recording their request, it wrote one when you requested this page; it also has to query a different table in the database to get the page content that you’re reading now.
The discovery I stumbled upon, the source of the massive speedup, is that I’ve added the keyword “DELAYED” to the statement that inserts the log entry into the statistics table. This instructs the database that the stats program does not care about waiting to know that the log was definitely, entirely, and completely written. Instead the Database immediately returns a happy message so the web server can get on with generating and sending the page.
So, if you’re using StatTraq and wish to hack it yourself, open up /plugins/stattraq.php and edit line 52 so that where it reads “INSERT INTO” the edited version reads “INSERT DELAYED INTO”.
One word, 90%+ speed increase. If only every thing could be so positive we’d have a cure for the common cold by bedtime.


July 12th, 2006 at 4:23 am
Works splendidly! GJ!!
January 29th, 2007 at 1:29 am
February 23rd, 2007 at 2:40 am