-
Notifications
You must be signed in to change notification settings - Fork 469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update tutorials to be more cognizant of CRDB vs. application language numeric types (esp. JavaScript) #4298
Comments
I recall this was an issue for the Twitter API when they moved to their current identifier system -- here's their doc on the topic. |
💯🙌 |
The way that I was solving this was by using Google’s UUID go library, but I’d guess snowflake or anything with a strong uniqueness guarantee that doesn’t have overflow/float issues would work (even mongo’s objectid) |
Also thank you guys for hopping on this! Love the response 👌 |
@rmloveland, is this SQL FAQ related? |
Sounds like a good idea, thanks @jseldess |
Fixes #4183, #4254. Addresses part of #3420, #4298. Summary of changes: - Add `default_int_size` to session vars page - Update `INT` data type page with new subsections of the **Size** section: - Description of compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using autogenerated JS clients - Why you should avoid integer primary keys, with links to more information in Perf Best Practices and the Architecture docs
Fixes #4183, #4254. Lays some groundwork for future work on #4298. Summary of changes: - Add `default_int_size` to session vars page - Update `INT` data type page with additions to the **Size** section, specifically: - A description of possible compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using frameworks that autogenerate frontend code. - Mention and link to `default_int_size` session var and cluster setting.
Fixes #4183, #4254. Lays some groundwork for future work on #4298. Summary of changes: - Update `INT` page to include examples of actual min/max integers supported by each type for easier reference. - Update `INT` data type page with additions to the **Size** section, specifically: - A description of possible compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using frameworks that autogenerate frontend code. - Mention and link to `default_int_size` session var and cluster setting. - Add `default_int_size` to session vars page
Fixes #4183, #4254. Lays some groundwork for future work on #4298. Summary of changes: - Update `INT` page to include examples of actual min/max integers supported by each type for easier reference. - Update `INT` data type page with additions to the **Size** section, specifically: - A description of possible compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using frameworks that autogenerate frontend code. - Mention and link to `default_int_size` session var and cluster setting. - Add `default_int_size` to session vars page
Fixes #4183, #4254. Lays some groundwork for future work on #4298. Summary of changes: - Update `INT` page to include examples of actual min/max integers supported by each type for easier reference. - Update `INT` data type page with additions to the **Size** section, specifically: - A description of possible compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using frameworks that autogenerate frontend code. - Mention and link to `default_int_size` session var and cluster setting. - Add `default_int_size` to session vars page
Fixes #4183, #4254. Lays some groundwork for future work on #4298. Summary of changes: - Update `INT` page to include examples of actual min/max integers supported by each type for easier reference. - Update `INT` data type page with additions to the **Size** section, specifically: - A description of possible compatibility issues caused by 64-bit integers vs. e.g. JavaScript runtimes, including when using frameworks that autogenerate frontend code. - Mention and link to `default_int_size` session var and cluster setting. - Add `default_int_size` to session vars page
I just had to solve this for a customer. They have an existing schema using As we've documented, the maximum numeric value that JS can represent without loss of precision is All of the usual caveats apply here about hash collisions, but you'd have to insert 111,000,000 values before there's a 50% chance of a collision occurring. CREATE TABLE js_friendly_id (
id INT8
CHECK (id >=0 and id < (1<<53) )
PRIMARY KEY
DEFAULT (fnv64a(unique_rowid()::string) & ((1<<53)-1)),
foo int);
INSERT INTO js_friendly_id (foo) SELECT generate_series(1,100000);
|
Richard Loveland (rmloveland) commented:
According to the
int_size
logic test, the return type ofunique_rowid()
isINT8
.According to the PG numeric data type docs,
INT8
is a bigint type with a max value of 9223372036854775807.However, JS numbers are 64-bit, which means they can only represent numbers up to 9007199254740991.
This is a pretty big mismatch! E.g.,
Estimated scope of work:
Related issues:
(h/t @markthethomas for this tweet that prompted filing this issue.)
Jira Issue: DOC-227
The text was updated successfully, but these errors were encountered: