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)
- Feature: Embedded replicas
- Bug: TIMEOUT not respected inside RETURN statement
- Bug: Rust fails to build surrealdb HOT 15
- Bug: Parser interpretes string id with starting with number followed by 'e' as exponenets HOT 2
- Bug: COMPOSITE INDEX does not work
- Bug: 'Unsupported value' in no-index WHERE condition, causes INDEX to not be used HOT 1
- Bug: The alphabetical order of the properties of an object-based Record ID is query-significant HOT 1
- Bug: HTTP CREATE not working when using TOKEN auth HOT 10
- Bug: Can't define a schema with flexible object keys HOT 4
- Bug: database fails and stop on attempt to delete namespace HOT 1
- Bug: the parse::url::port() does not work on https url HOT 3
- Bug: Parse error when using RELATE query from docs
- Feature: NN Vector search and similarity masking (partial vector search)
- Bug: Floats treated as integers and duplicate records not checked when floats used as record id
- Bug: Http endpoint empty response HOT 3
- Bug: Strand does not check for nul bytes in release mode
- Bug: New parser does not work with backticks HOT 3
- Bug: CLI handling of version check not working HOT 1
- Bug: "No Iterator has been found" when mixing indexes HOT 1
- Bug: REPL exits immediately HOT 4
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.