I like the auto-increment primary key method for unique ID's in MySQL, however, if 
your table's design will not allow you to use that for some (unknown to me) important 
reasons, you could programmatically generate a truly unique ID and INSERT that.  

Did you try a Google under GUID?  http://tinyurl.com/2l34e  I don't recall an 
algorithm offhand, but I believe one might typically use a number of variables to 
generate a GUID (like date-time, IP, a random number, etc.)  This is a well explored 
area of CS, I believe, and wouldn't require you to reinvent the wheel.

Eric


> ------------Original Message------------
> From: Jeff Mathis <[EMAIL PROTECTED]>
> To: [EMAIL PROTECTED]
> Cc: "Keith C. Ivey" <[EMAIL PROTECTED]>, [EMAIL PROTECTED]
> Date: Thu, Feb-12-2004 11:13 AM
> Subject: Re: Unique IDs
> 
> as everyone has pointed out, using timestamps as a unique id was a 
> design flaw. you should fix the problem using an auto-increment field.
> 
> that said, can you change the column type you are currently using as a 
> timestamp to be an auto-increment int field? the return type in both 
> cases is technically an integer for mysql versions < 4.1, but your API 
> call may need to be changed nevertheless.
> 
> my experience has always been to fix the problem right rather than do a 
> hork, even if it means down time.
> 
> jeff
> Craig Jackson wrote:
> > On Thu, 2004-02-12 at 11:47, Keith C. Ivey wrote:
> > 
> >>Craig Jackson <[EMAIL PROTECTED]> wrote:
> >>
> >>
> >>>I have a very large web app that uses timestamp for unique IDs.
> >>>Everything was rolling fine until we started getting many users per
> >>>second, causing some of the unique IDs to not be unique -- users were
> >>>being assigned the same timestamp. Since the web app is so large we
> >>>don't want to change the method of assigning IDs as it would create a
> >>>major project.
> >>
> >>I don't understand.  If you're getting many users per second, and 
> >>your timestamps have 1-second resolution, how could you possibly 
> >>solve the problem without changing the method of assigning IDs?
> >>Are the "many users per second" periods just short bursts, and you're 
> >>really only getting several hundred users per day?  If so, I guess 
> >>you could keep waiting a second and trying the insert again, but that 
> >>could lead to indefinite delays if traffic gets high.  I think you've 
> >>got to bite the bullet and change the unique ID to something that's 
> >>actually unique -- even an AUTO_INCREMENT would work.
> > 
> > 
> > Thanks for the speedy reply and I have already recommended
> > auto_increment for the solution. We do need that quick fix until the
> > problem is fixed. How would I go about making Mysql wait one second
> > between inserts. We only get about 1000 hits per day, but they tend to
> > be concentrated in short time intervals.
> > 
> > 
> > 
> >>-- 
> >>Keith C. Ivey <[EMAIL PROTECTED]>
> >>Tobacco Documents Online
> >>http://tobaccodocuments.org
> > 
> > 
> > 
> 
> 
> -- 
> Jeff Mathis, Ph.D.                    505-955-1434
> The Prediction Company                        [EMAIL PROTECTED]
> 525 Camino de los Marquez, Ste 6      http://www.predict.com
> Santa Fe, NM 87505
> 
> 
> -- 
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]
> 
> 
> 
> 

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to