What is the best practices to generate UUID (PRIMARY KEY) let it generate at Mysql end OR let it generate at PHP end
doing some performances test i find generating it at php end is a bit faster
but doing some Google i find many are practicing it to generate at MySQL end http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram
so what would be the right way to do so for an continuously growing data ?
If you wish to insert rows from different applications then generating the UID via the DB is the safest method because the implementation is centralised and of course won't change between applications.
Let's say you decide to create an API in another language. You would then need to implement the same generator in that language. There might be differences in the way this other language implements functions you rely on to generate key data, which lead to duplicate keys.
If you are only going to be inserting rows from PHP on your own server, it doesn't matter if you generate UIDs in the application or the DB.
Safe isn't always right. Or practical. Weigh up the pros and cons of your intended use cases and go from there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With