UUID or bigserial for primary key

Hi!
Should I use bigserial/bigint or UUID as Primary key at Yugabyte?
We think it is much more reasonable to use bigserial because big serial is 8byte and UUID is 16byte.
Are there any advantageous or disadvantageous of using bigserial or UUID?

Or are there any other unique types that hold 8 byte of space and like UUID(no-collision)?
Thanks!

Hi, I’ve written about it:

Bigserial is not so nice because you can’t set the sequence cache. bigint generated always as identity is good. I like UUID when exposed to the users so that it doesn’t disclose any info. But primary keys should not be exposed anyway.

There is twitter snowflake id. But you have to generate them in your client code.

@FranckPachot @dorian_yugabyte Thanks for your fast anwers!

It looks like I can use Snowflake. I have a column that holds a date named CreatedDate and it looks like I can use the timestamp at primary key (snowflake) instead of that column.
I will storage Snowflake in bigint (8byte-64bit) type at Yugabyte, is it correct?

Assuming you are generating them correctly, yes.

1 Like