Comments (5)
Thanks @Ikki-Dai. We used to use xid
for record IDs, and I can't remember why we changed it to the current implementation, but I can look at this again. This is based on the Golang xid
library.
To summarise, there are a few reasons that an xid
could be an improvement on snowflake ids...
The binary representation of the id is compatible with Mongo 12 bytes Object IDs. The string representation is using base32 hex (w/o padding) for better space efficiency when stored in that form (20 bytes). The hex variant of base32 is used to retain the sortable property of the id.
Xid doesn't use base64 because case sensitivity and the 2 non alphanum chars may be an issue when transported as a string between various systems. Base36 wasn't retained either because 1/ it's not standard 2/ the resulting size is not predictable (not bit aligned) and 3/ it would not remain sortable. To validate a base32 xid, expect a 20 chars long, all lowercase sequence of a to v letters and 0 to 9 numbers ([0-9a-v]{20}).
UUIDs are 16 bytes (128 bits) and 36 chars as string representation. Twitter Snowflake ids are 8 bytes (64 bits) but require machine/data-center configuration and/or central generator servers. xid stands in between with 12 bytes (96 bits) and a more compact URL-safe string representation (20 chars). No configuration or central generator server is required so it can be used directly in server's code.
Specifically this part:
Twitter Snowflake ids are 8 bytes (64 bits) but require machine/data-center configuration and/or central generator servers.
Name | Binary Size | String Size | Features |
---|---|---|---|
[UUID] | 16 bytes | 36 chars | configuration free, not sortable |
[shortuuid] | 16 bytes | 22 chars | configuration free, not sortable |
[Snowflake] | 8 bytes | up to 20 chars | needs machine/DC configuration, needs central server, sortable |
[MongoID] | 12 bytes | 24 chars | configuration free, sortable |
xid | 12 bytes | 20 chars | configuration free, sortable |
Therefore if we decide on this, then xid would be a better choice.
Would this work @Ikki-Dai ? Let me know your thoughts.
from surrealdb.
Hi @Ikki-Dai thanks for this feature request. Just 2 questions:
- Can I ask why specifically a Snowflake ID?
- And also, what are the issues that you have with the current record ID?
from surrealdb.
-
Snowflake ID can provide compatibility with other RDBMS, they aways use an increment or sequence as id column.
And lots of project use long type or other number type as designed.
Snowflake ID can also be used in a distribute system in the feature. -
current record id is good. and it is designed for mutlti store models.
from surrealdb.
Thanks @tobiemh, i found the xid lib. it seems a snowflake like implementation. If that were the case, everything is ok now.
from surrealdb.
As of commit bb0b10e this should now be possible! This functionality will be generally available in 1.0.0-beta.9
.
CREATE person:ulid() SET name = 'Tobie';
from surrealdb.
Related Issues (20)
- Bug: Transaction could not check for conflicts for operation at SequenceNumber 3335132 as the MemTable only contains changes newer than SequenceNumber 3335133 HOT 1
- Bug: enable scripting config doesn't work for Rust in-memory embedded mode HOT 4
- Bug: use table name inside query in rust as bind not working properly.
- Make release and beta workflows idempotent
- Bug: Abnormal memory usage (v3) HOT 7
- Bug: time not implemented on this platform
- Bug: Inconsistent Performance behavior in SurrealQL queries
- Docker images for Windows 2019/2022 server HOT 1
- Bug: Nested FOR loop does not iterate through elements in an array
- Bug: unique Index on edge table doesn't allow modification HOT 1
- Bug: database level user doesn't work HOT 4
- Feature: Map arrays into string HOT 1
- Feature: Parquet file support
- Feature: Select statement should use the index when not filtering data
- Bug: optional field is checked before `VALUE` clause is executed HOT 5
- Feature: DBA tools (list active connections/queries)
- Bug: Renaming type::field doesn't rename the field
- Feature: Optimized release builds for popular arhitectures HOT 2
- Bug: SELECT is far slower when using a index compared to unindexed HOT 1
- Bug: Define field implicitly defines table
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from surrealdb.