Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Generate a unique ID

by TheRatKing (Initiate)
on Nov 15, 2010 at 19:18 UTC ( #871551=note: print w/ replies, xml ) Need Help??


in reply to Generate a unique ID

I have databases with over 750k entries using UUID for each row and have never ran into a collision -- over a 2 year period. Are you storing this unique ID somewhere? Otherwise why would the same ID matter? If you are storing this ID, then you may be able to just check a newly generated UUID against your database and generate a new one if collision does occur. But you will find that part of your code will be practically dead code anyway because it will not find any collision. So don't bother. Just use UUID, go on to implement something cool first. And if UUIDs are colliding because your program is so popular it is being used millions times per second, then come back to solve this problem.


Comment on Re: Generate a unique ID
Re^2: Generate a unique ID
by BrowserUk (Pope) on Nov 15, 2010 at 19:30 UTC
    I have databases with over 750k entries using UUID for each row and have never ran into a collision -- over a 2 year period.

    How do you know you've never had a collision? Are you checking, if so how?

    And are you using Data::UUID? On Windows?

    If you're using this to give every new record a unique id, why aren't you using an autoincrmenting primary key?


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

      Yes, I do check for collisions because I was also curious.

      I'm not using an autoincrementing primary key because an autoincrementing primary key depends on the state of the table within a given database. My data sits in Google App Engine for production and sits in a postgresql database as the primary source for when I need to curate it. (Processing directly on G.A.E. costs more than transferring the difference periodically.)

        Yes, I do check for collisions

        Could you describe how please?


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://871551]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (7)
As of 2014-12-27 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls