Is it good to convert UUID to BIGINT in Postgres 9 so that globals are generated in distributed clients?

I will have several distributed clients that mirror some tables in a centralized postgres 9 database. The system will work as a two way data sync. Clients can be offline for hours and days at worst (these are mobile clients for field data collection)

So, I need to do inserts in clients and generate a global id for them. I currently have a GUID field for this, but accidentally looking at http://docs.python.org/2/library/uuid.html to find that the GUID can be converted to INT64 or BIGINT.

So I am wondering if it is correct to generate a GUID in the client, convert it to BIGINT and use it as the primary key in the database (because it is faster or cheaper to join and search by INTs than GUIDs or characters)

+3


source to share


1 answer


Dropping the GUID into 64-bit INT64 or BIGINT sounds like a bad idea since the UUID is 128 bits long.



Also, the database does not store the GUID / UUID as a string, it stores it as a 128 bit number, which is a fairly optimal and easily indexed format.

+3


source







All Articles