MySQL Forums :: Performance :: best way to generate a random unique id


Advanced Search

best way to generate a random unique id
Posted by: Peter O'Malley ()
Date: July 02, 2011 03:32AM

I have a database with a table of users, and would like to assign a random, unique id to each user. I will need to tell each user what their id is, but I don't want to disclose any information to users about the number of users in the table, which is why the id has to be random. What is the best way to generate a random and unique id, with minimal cost to performance?

I've seen comments about the built-in UUID() function, and have heard that using it to fill a column every time a row is inserted can lead to performance issues, or collation and indexing issues. I've also seen comments saying that the function shouldn't be used because it's old or outdated. Is there a better alternative to UUID()? How does the performance cost compare?

Thanks for any help.

Options: ReplyQuote


Subject Views Written By Posted
best way to generate a random unique id 11171 Peter O'Malley 07/02/2011 03:32AM
Re: best way to generate a random unique id 17816 Rick James 07/03/2011 10:36AM
Re: best way to generate a random unique id 2851 Peter O'Malley 07/05/2011 09:17AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.