|Subject||Re: Hits and stats counters ....|
My suggestion would be - not to use update, but insert on separate table for hits - and make a scheduler task for daily(weekly) counting records and cleaning that table (you may add a timestamp to each record to filter them in cleaning task) You also will get more information from that.
--- In firstname.lastname@example.org, Lester Caine <lester@...> wrote:
> masotti wrote:
> > Hi Lester,
> > Lester Caine wrote:
> >> I've had a problem with bitweaver since day one, but since it only happened very
> >> occasionally I'd chosen to ignore it. With the traffic through my sites
> >> increasing it has become a more serious problem, and I need to look at doing
> >> something about it.
> >> Query is simple enough
> >> UPDATE LC_HITS SET hits = hits + 1, last_hit = NOW WHERE content_id = xxx
> > Default transactions are IBASE_WRITE | IBASE_CONCURRENCY | IBASE_WAIT,
> > so you need to alter default transaction in client library to IBASE_READ
> > | IBASE_COMMITED | IBASE_REC_VERSION | IBASE_NO_WAIT.
> ADOdb default is IBASE_WAIT | IBASE_REC_VERSION | IBASE_COMMITTED
> Should I need to add IBASE_READ to that, and why not IBASE_WAIT there ?
> > To update database don't use default connection, but peek another
> > connection from pool and use an explicit transaction.
> > To peek a different connection from pool to the same database may work
> > if you define a different user or a different connection character set
> > so both connection will be pooled.
> > $db0 = ibase_pconnect ( $dbase, $another_user, $another_pass );
> > $trx = ibase_trans ( IBASE_WRITE | IBASE_COMMITTED |
> > IBASE_RECORD_VERSION | IBASE_WAIT, $db0 );
> > $qry = "LC_HITS SET hits = hits + 1, last_hit = NOW WHERE content_id = xxx";
> > $cnt = ibase_query ( $db0, $qry );
> > ibase_commit ( $tr0 );
> > This is only theory, never had chance to test.
> I was considering adding an 'update' connection - I have used that in the past,
> but only on windows apps where the main connection may be open for some time (
> with packaged transactions ). Up until now I'd not considered it necessary since
> PHP packages up each page and should not be holding anything open? THAT is why
> the deadlock seems to be strange since the only 'update' reading pages is the
> hits counter.
> I've switched daily stats off at the moment - that updates a set of count
> records for a single day and gives the same problem :(
> Lester Caine - G8HFL
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk//
> Firebird - http://www.firebirdsql.org/index.php