Actually, with a pconnect, there would be a trade off. Since it uses a
shared connection, the last insert ID could change between the update
and calling the api function. But as I said, it doesn't matter for the
counter.

Matthew Walker
Senior Software Engineer
ePliant Marketing
 

-----Original Message-----
From: Benjamin Pflugmann [mailto:[EMAIL PROTECTED]] 
Sent: Sunday, April 14, 2002 9:47 PM
To: Matthew Walker
Cc: Craig Westerman; MySQL List
Subject: Re: MySQL counter for HIGH traffic site

Hi.

There is a one-query method to do that and it is even explicitly
documented: http://www.mysql.com/doc/M/i/Miscellaneous_functions.html
(under LAST_INSERT_ID([expr])). This requires an UPDATE and using a
client API function like mysql_insert_id(). No locks needed and the
operation is atomic (i.e. no 'precision' trade-off).

Bye,

        Benjamin.

On Sun, Apr 14, 2002 at 09:11:03PM -0600, [EMAIL PROTECTED]
wrote:
> I'd recomment PHP4 using pconnect and MySQL. And I'd /not/ use locking
> on the table. Run a query to update the row, then run a select to grab
> the current total. In the case of a counter, it doesn't require the
> precision that most things would. (i.e., it's okay if the row you read
> doesn't have the value you just set in the update.)
> 
> As far as performance goes, my PHP app can do 40+ queries in less that
> .05 seconds. So you shouldn't have problems there.
[...]

-- 
[EMAIL PROTECTED]


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.345 / Virus Database: 193 - Release Date: 4/9/2002
 

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to