tags:

views:

49

answers:

3

We know that it is easy to create auto increment IDs in SQL databases, iS there a good solution for it in Cassandra? The IDs should be for key or column name.

A: 

Snowflake

Schildmeijer
Hi Schildmeijer, we are moving data from SQL Server to Cassandra, the IDs are auto increased like 1,2,3,4,5,6,...It looks like Snowflake cannot generate like this way, its ID contains time, machine id and sequence number.
Andy Wan
A: 

There is no good solution.

  1. Create a column with a number, increase the number and save it to all replicas together with a temporary id, read all replicas and check if the temporary id is "yours", if not do it again.. not a great solution and will not scale.

or

  1. Build your own id service where you fetch your next id. This service will only be run in a single instance and will be a non scaling scary factor.

As soon as anything goes beyond a single instance the sequencing of id's gets complicated, at least if you want it to scale. That includes relational databases.

Simon Karlsson
A: 

Creating a global sequential sequence of number does not really make any sense in a distributed system. Use UUIDs.
(Because you would have to make all participants agree and accept the evolution of the sequence -- under a naive implementation)

Luis Matta