8/17/2023 0 Comments Mysql uuid not unique![]() many gaps in sequence suggest there are many rolled back transactions. But if we change our rationale context to debugging, serial values give a direct hint about what’s going on inside, e.g. To test it I wrote a 1 – only if we’re talking about general purpose (application, final) sorting. Since we know that searching (select * from table where id = …) will have virtually the same speed, let's see how fast does it take to load data. If you have such case, please let me know in comments.įinally, out of curiosity, let's try to see some performance tests. Of course there might be some situations where UUID is the only acceptable solution. If you need something that will allow sharing ids between multiple machines – check instagram ids (which I coded in C and pl/PgSQL in this blogpost. If you need just unique value – int8 sequence/identifier will be usually more than enough. It uses 16 bytes per value, which is twice what is used by int8.īased on these problems – my point is that in majority of cases, you don't really need or want uuid, and can use simpler keys. Well, you can use uuid_generate_v1() but it has the drawback of containing also some form of MAC. ![]() Second problem – you can't use uuids to sort in a way that gives you newest rows first. I can make some guesses about expected number of rows, or their order. ![]() If you're using natural keys, or something like serial, and you have two tables with very different numbers of rows, you can, usually see that value “12345678" doesn't really look OK as a key in table that has ~ 1000 rows.Īdditionally, looking at list of uuids doesn't really give you any insight:ĭoesn't mean anything to me. That means – uuids generated for table sessions will be indistinguishable from the ones for table users. ![]() I opposed, and tried to explain, but IRC doesn't really allow for longer texts, so figured I'll write a blogpost.įirst problem – UUID values are completely opaque. Recently, on irc, there were couple of cases where someone wanted to use uuid as datatype for their primary key. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |