0

I require to have a table in my Cassandra that need to have any number(bigint) as primary key type. For eg., here is my table:

CREATE TABLE users (id bigint PRIMARY KEY,username text,email text,age int);

Now, whenever with uuid as primary key, we can autoincrement using now() or uuid(), what option do I have for numeric primary key?

If using a numeric primary key is an awful idea, suggest a function(perfect hash) that can convert any uuid to numeric form and if at all possible, vice-versa.

Yep. You guessed it right. RDBMS background guy.

Sachin Verma
  • 3,712
  • 10
  • 41
  • 74
  • https://stackoverflow.com/a/29391877/2320144 – Ashraful Islam Nov 27 '17 at 13:13
  • You can treat your uuid as a number if you really want, its just a bunch of bits and can be treated as anything. Having an auto-incrementing number thats unique requires coordination which in a distributed system is inherently expensive. Using now() is a great solution which will provide you 10,000 unique ids per ms per node without coordination. – Chris Lohfink Nov 28 '17 at 01:58

0 Answers0