-
Notifications
You must be signed in to change notification settings - Fork 451
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
Create FAQs for numbering problems. #3104
Conversation
Reviewed 4 of 4 files at r1. _includes/faq/sequential-numbers.md, line 5 at r1 (raw file):
So we should recommend that if you need a roughly-ordered id, use v2.0/sql-faqs.md, line 21 at r1 (raw file):
I don't think "totally order" is the right term to use here. All rows in CRDB are totally ordered in the mathematical sense . The question here is how to make that total order correspond with insertion order. Comments from Reviewable |
Amended based on Ben's suggestion. Also added a comparison table. RFAL. Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions. _includes/faq/sequential-numbers.md, line 5 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Thanks for reminding me. Amended. v2.0/sql-faqs.md, line 21 at r1 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Yes, you're right. Rephrased. Comments from Reviewable |
Reviewed 5 of 5 files at r2. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file):
The locality issue is not about insert contention: unique_rowid values are extremely unlikely to directly contend with each other. The difference between unique_rowid and UUID is parallelism: looking up values by a UUID can make use of many nodes because the values will be spread across many ranges. Typical queries by a more time-ordered id will create more hotspots. v2.0/sql-faqs.md, line 37 at r2 (raw file):
Add this to the 2.1 docs too. Comments from Reviewable |
Review status: 3 of 5 files reviewed at latest revision, 2 unresolved discussions. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
I reworded, can you have another look? v2.0/sql-faqs.md, line 37 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
It is there already. Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, knz (kena) wrote…
For "data locality" and "read performance", sequences and unique_rowid are equivalent. We don't need to make a distinction between them except for insert performance. _includes/faq/differences-between-numberings.md, line 9 at r3 (raw file):
Break "insert performance" into latency and throughput buckets. For latency, both uuid and unique_rowid have good latency while sequences are slower. For throughput, UUID has best throughput while unique_rowid and sequences are limited. Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Well I don't agree with that. Two rowids generated a day apart will have values far apart. Sequences are guaranteed to be close to each other. Or are you saying that the "value distance" due to time distance for rowids does not matter? _includes/faq/differences-between-numberings.md, line 9 at r3 (raw file): Previously, bdarnell (Ben Darnell) wrote…
The latency increases under contention, doesn't it? Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, knz (kena) wrote…
The "value distance" only matters if there are other keys between them. Each key will (usually) be adjacent to the one generated before it, whether the difference between the keys is 1 or 1000. _includes/faq/differences-between-numberings.md, line 9 at r3 (raw file): Previously, knz (kena) wrote…
Yes. Under low traffic, UUID and unique_rowid will have the same latency. As traffic increases, unique_rowid latency will degrade while UUID insertion latency will stay the same. Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Check. Now I get it (I think). _includes/faq/differences-between-numberings.md, line 9 at r3 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Ok updated. Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, knz (kena) wrote…
For the data locality line, I think both unique_rowid and sequences are "highly local". There's not a meaningful difference between the two. Similarly, what difference is "somewhat time-ordered" vs "highly time-ordered" supposed to indicate? I'd say that both are equally time-ordered. I think the amount of concurrency required to have out-of-order insertions is similar for both. Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions. _includes/faq/differences-between-numberings.md, line 7 at r2 (raw file): Previously, bdarnell (Ben Darnell) wrote…
Yes ok I agree with this too. Comments from Reviewable |
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions, all commit checks successful. Comments from Reviewable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome, @knz. LGTM, with some nits and minor copyedits. Nothing glaring though, so I'll merge and make edits in a follow-up PR.
|
||
{% include faq/sequential-numbers.md %} | ||
|
||
~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this extra empty code block.
|
||
{% include faq/sequential-numbers.md %} | ||
|
||
~~~ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this extra empty code block.
Sequential numbers can be generated in CockroachDB using the built-in | ||
function `unique_rowid()` or using [SQL sequences](create-sequence.html). | ||
|
||
{{site.data.alerts.callout_info}}Unless you need roughly-ordered |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to use <code></code>
instead of backticks within a callout.
write ordering can be solved with other, more distribution-friendly | ||
solutions instead. For example, CockroachDB's [time travel queries | ||
(`AS OF SYSTEM | ||
TIME`)](https://www.cockroachlabs.com/blog/time-travel-queries-select-witty_subtitle-the_future/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once https://github.com/cockroachdb/docs/pull/3018/files lands, we'll have a specific doc page to link to here, which I think it preferable to the blog post.
- initially: `CREATE TABLE cnt(val INT PRIMARY KEY); INSERT INTO cnt(val) VALUES(1);` | ||
- in each transaction: `INSERT INTO cnt(val) SELECT max(val)+1 FROM cnt RETURNING val;` | ||
|
||
This will cause all your INSERT transactions to conflict with each |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should code-format INSERT
here.
As discussed on cockroachdb/cockroach#9227 and other related issues.
Jesse please take this over.