Log in

No account? Create an account

Page Counters, A different approach...

« previous entry | next entry »
Jul. 1st, 2007 | 10:13 pm

I just noticed PeterZ's post on page counters:

Let me offer a different solution.

Do not do it.

Really, if you grow a site to any size at all you will discover that
the contention you create on updates is just too much. Sure, you can
optimize it by have the update done on a de-normalized table, but
unless you are using 5.1 with its row level replication, eventually
the replication locks will nail you.

Instead build an accesslog type table. You probably already have one,
aka you are recording your accesslog in your database. Just run a job
every so often that updates the counter on your object in its own
table (which will save you on the select if it is useful to have a
historical count on the object).

If you want a simple logger to MySQL, I keep mine here:

Link | Leave a comment |

Comments {1}


(no subject)

from: peter_zaitsev
date: Jul. 2nd, 2007 09:04 am (UTC)


I'm not sure where exactly you disagree with my post, using access log type table is exactly one of optimizations I mention in my article.

Anyway you can see full reply back in my blog :)

Reply | Thread