You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The uuid key autogen scheme we use isn't enough. We should allow picking an autogen scheme at table creation. Here are some alternative schemes we should support:
Approximately chronological (e.g. non-colliding timestamps, roughly ordered)
Approximately ordered (e.g. incrementing from zero, roughly ordered)
Yes, the snowflake approach would probably be the first one we implement once we add another autogeneration scheme (I also suspect that coupled with the current scheme, it will be enough for most people).
I agree, Snowflake or something similar to MongoDB would be neat. Although not too different than UUIDs they are shorter [nicer in urls] and a bit easier to pass around.
For those watching this issue, this almost certainly won't happen until Rethink hits 2.0 -- sorry. Between UUID and upcoming date support, people should be able to find workarounds for almost every use case. While additional generation schemes are really nice, unfortunately there are much more important things we have to do first.
If you run into a use case where this is a real showstopper, please let us know and we'll see if we can reprioritize.
Two thoughts, regarding migrations from other databases to Rethink and string representation.
When moving from MongoDB/MySQL to Rethink it's nice to use a uniform id format. It would be good if the Rethink ID function could both generate them randomly (normal method of operation) or based on a seed (which would be the old id from another structure).
For example:
rdbUuidFunction('mysql_table_name-1') => '1u7v7tzap6ua18f6lyr' // mysql to rethink
rdbUuidFunction('5318cd64421aa9f2e800002d') => '40aubkd55r8yhoo2qr' // mongodb to rethink
This use-case would be only for migrations, and it would always generate the same output for one input string.
It would leave it to the developer to ensure that the input is unique (i.e. database_table_id for e.g. MySQL and another unique id for e.g. MongoDB.
I know nothing about database design and choice of id algorithms, but having an id where the string representation is short (and url compatible) is neat, i.e. [a-z0-9] [alpha num] is better than [a-f0-9] [hex].
@sandstrom -- in case of a migration, why not just use the original ID as the new RethinkDB ID? (unless you want IDs for old data and new data to look consistent, which is the only consideration I can think of at the moment)
@coffeemug The thing I thought of was consistency. Maybe it's just my OCD :) (but I think others may find it useful too). And for some types of uuid generation it would not be difficult to include.
@sandstrom, not sure that's a good idea – you're going to completely break relationships between records that use the ID field. This is really something that would need to be scripted for your particular situation.
Perhaps considering additional flexability would be usefull. For example, we don't like the hyphens in our UUID's. It would be nice if it was possible to remove these
Reacted by tmx976, David Koerdt, Timofey Suchkov, Alec Larson and Gábor Boros
wondering why we don't have a simple increasing int, I know this might hurt performance to do a global lock on the database, but it would be useful for some application types.
So we would need to run something like this atomically:
@thelinuxlich are you sure this is really an issue? I've imported a table with an auto-incrementing id from a MySQL-Server and this is the data-distribution:
@RubenKelevra are you sure your primary keys are numbers and not in fact strings? Range sorting the string representations of auto incremented ints would balance, although not in the order you would expect of numbers.
Also, how did you do the import? If you used a bulk utility, it’s possible it ran a rebalance for you; also, if you changed the sharding or replication strategies after your initial import or added/removed nodes, you likely triggered a rebalance.
Activity
pzol commentedon May 30, 2013
You probably are aware how mongodb creates its ids? This is similar to twitter snowflake. The hidden timestamp is a great bonus
http://docs.mongodb.org/manual/reference/object-id/
coffeemug commentedon May 30, 2013
Yes, the snowflake approach would probably be the first one we implement once we add another autogeneration scheme (I also suspect that coupled with the current scheme, it will be enough for most people).
sandstrom commentedon Jul 31, 2013
I agree, Snowflake or something similar to MongoDB would be neat. Although not too different than UUIDs they are shorter [nicer in urls] and a bit easier to pass around.
coffeemug commentedon Aug 6, 2013
For those watching this issue, this almost certainly won't happen until Rethink hits 2.0 -- sorry. Between UUID and upcoming date support, people should be able to find workarounds for almost every use case. While additional generation schemes are really nice, unfortunately there are much more important things we have to do first.
If you run into a use case where this is a real showstopper, please let us know and we'll see if we can reprioritize.
bryanhelmig commentedon Nov 4, 2013
👍 for this.
The UUIDv1 scheme could work, although the MAC address encoding would probably be replaced with a random seed.
sandstrom commentedon Mar 11, 2014
Two thoughts, regarding migrations from other databases to Rethink and string representation.
When moving from MongoDB/MySQL to Rethink it's nice to use a uniform id format. It would be good if the Rethink ID function could both generate them randomly (normal method of operation) or based on a seed (which would be the old id from another structure).
For example:
This use-case would be only for migrations, and it would always generate the same output for one input string.
It would leave it to the developer to ensure that the input is unique (i.e.
database_table_idfor e.g. MySQL and another unique id for e.g. MongoDB.I know nothing about database design and choice of id algorithms, but having an id where the string representation is short (and url compatible) is neat, i.e.
[a-z0-9][alpha num] is better than[a-f0-9][hex].coffeemug commentedon Mar 11, 2014
@sandstrom -- in case of a migration, why not just use the original ID as the new RethinkDB ID? (unless you want IDs for old data and new data to look consistent, which is the only consideration I can think of at the moment)
sandstrom commentedon Mar 12, 2014
@coffeemug The thing I thought of was consistency. Maybe it's just my OCD :) (but I think others may find it useful too). And for some types of uuid generation it would not be difficult to include.
mike-marcacci commentedon Apr 10, 2014
@sandstrom, not sure that's a good idea – you're going to completely break relationships between records that use the ID field. This is really something that would need to be scripted for your particular situation.
sandstrom commentedon Apr 10, 2014
@mike-marcacci Yes, foreign keys must be updated too, naturally.
coffeemug commentedon Aug 14, 2014
Note, this is related to #2063.
15 remaining items
mbrevda commentedon Sep 26, 2015
Perhaps considering additional flexability would be usefull. For example, we don't like the hyphens in our UUID's. It would be nice if it was possible to remove these
coffeemug commentedon Sep 26, 2015
👍
DeividasJackus commentedon Mar 9, 2016
Hopefully this proves to be of some value... I find it to be a pretty elegant solution: Sharding & IDs at Instagram
xfg commentedon Jul 16, 2016
+1 for human-readable ids
RubenKelevra commentedon Aug 2, 2017
wondering why we don't have a simple increasing int, I know this might hurt performance to do a global lock on the database, but it would be useful for some application types.
So we would need to run something like this atomically:
r.db('nodes').table('basicdata').insert({'id': r.db('nodes').table('basicdata').max('id').getField('id')+1 })thelinuxlich commentedon Aug 2, 2017
The problem with autoincrementing ids is that RethinkDB uses range sharding, so you would need to run rebalance() on the table often.
RubenKelevra commentedon Aug 2, 2017
@thelinuxlich are you sure this is really an issue? I've imported a table with an auto-incrementing id from a MySQL-Server and this is the data-distribution:
thelinuxlich commentedon Aug 2, 2017
I'm sure it's a issue
RubenKelevra commentedon Aug 2, 2017
@thelinuxlich forgive me the noobish question, but why is my table in this case perfectly balanced?
thelinuxlich commentedon Aug 2, 2017
I don't have the technical knowledge to explain it, but I've tested inserting millions of records and the final result is unbalanced.
mike-marcacci commentedon Aug 2, 2017
@RubenKelevra are you sure your primary keys are numbers and not in fact strings? Range sorting the string representations of auto incremented ints would balance, although not in the order you would expect of numbers.
Also, how did you do the import? If you used a bulk utility, it’s possible it ran a rebalance for you; also, if you changed the sharding or replication strategies after your initial import or added/removed nodes, you likely triggered a rebalance.
RubenKelevra commentedon Aug 3, 2017
@mike-marcacci yes - type is int.
Imported by webui and simple r....insert({...}) a JSON dump of a MySQL Database-query.
Because my export contains only strings, I‘ve bulk converted the export with sed to get an int as primary key and floats to be floats etc.
I haven’t changed the geometry of the database table after import.
chore(board): tick rethinkdb#117 — RT-GAP-007 stale pause request rem…
chore(board): tick rethinkdb#117 close — RT-GAP-009 COMPLETE (117da58)…
chore(board): tick rethinkdb#118 — RT-GAP-004 COMPLETE (b79117a, READ…