-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
rfc: sql interleaved tables #7465
Conversation
522fd5a
to
cb71bee
Compare
Review status: 0 of 1 files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 62 [r1] (raw file):
docs/RFCS/sql_interleaved_tables.md, line 77 [r1] (raw file):
I think you need to add some additional bits here about how interleaved keys affect various SQL operations. In particular, deleting multiple contiguous rows from either the parent or the child interleaved table is more problematic as we can't use a single docs/RFCS/sql_interleaved_tables.md, line 92 [r1] (raw file):
It would be good to try and avoid splitting in the middle of the interleaved data. That would require being able to examine a key and determine if it is for an interleaved table without any additional information. I'm not sure if that is possible with the proposed encoding. docs/RFCS/sql_interleaved_tables.md, line 96 [r1] (raw file):
Agreed, creating the constraint automatically doesn't seem necessary, though perhaps there might be a shorthand to create such a constraint. Comments from Reviewable |
Reviewed 1 of 1 files at r1. docs/RFCS/sql_interleaved_tables.md, line 92 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 92 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 92 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 92 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 4 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 92 [r1] (raw file):
|
Nice! Review status: all files reviewed at latest revision, 5 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 36 [r1] (raw file):
I am wondering how schema changes will be possible if we require this at all times. A statement to change the schema of either wouldn't be possible without breaking this constraint, but then there is no way to chnage both at the same time either.. Related - will it be possible to "break" an interleave relationship? And will it be possible to create an interleave relation on an existing table? I think it's reasonable if the answer to these questions is "no", at least for the time being (but should be spelled out). docs/RFCS/sql_interleaved_tables.md, line 77 [r1] (raw file):
|
Another question to think about - will we support interleaving a secondary index? Starting from your example, imagine the orders table uses an order ID as the primary key (and not the customer ID); but we want to have an index on (customerID, orderID) and interleave that index with the customer table. Review status: all files reviewed at latest revision, 5 unresolved discussions, all commit checks successful. Comments from Reviewable |
Reviewed 1 of 1 files at r1. docs/RFCS/sql_interleaved_tables.md, line 36 [r1] (raw file):
|
Review status: all files reviewed at latest revision, 5 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 36 [r1] (raw file):
|
Thanks for the reviews, everyone! RFAL Secondary index interleaving is interesting, but I wonder if the additional complexity is worth it. Review status: 0 of 1 files reviewed at latest revision, 5 unresolved discussions, some commit checks pending. docs/RFCS/sql_interleaved_tables.md, line 36 [r1] (raw file):
|
Reviewed 1 of 1 files at r2. docs/RFCS/sql_interleaved_tables.md, line 36 [r1] (raw file):
|
Reviewed 1 of 1 files at r2. Comments from Reviewable |
I've been convinced that we should look at secondary index interleaving. I'll add it in Review status: all files reviewed at latest revision, 5 unresolved discussions, some commit checks failed. Comments from Reviewable |
Updated with secondary index interleaving @RaduBerinde Also swapped DO NOTHING for RESTRICT, which is what we're already using for this in foreign keys Review status: 0 of 1 files reviewed at latest revision, 5 unresolved discussions, some commit checks pending. Comments from Reviewable |
Reviewed 1 of 1 files at r3. docs/RFCS/sql_interleaved_tables.md, line 57 [r3] (raw file):
s/train/strain/ docs/RFCS/sql_interleaved_tables.md, line 88 [r3] (raw file):
Couldn't more families exist, just with a gap at docs/RFCS/sql_interleaved_tables.md, line 110 [r3] (raw file):
I would expect all of this logic to be pretty complicated. If you make no assumptions about the size of the interleaved data, you really cannot afford to just scan all of it (scanning 10 users shouldn't send all of these users' orders back). I have the impression that some rudimentary SQL awareness of KV scans could really go a long way here. Is it really better to implement all of this on the current KV store, when it is kind of clear that KV needs to learn about SQL keys for this to work performantly? Or am I overestimating the likelihood of that happening? Discussing how some operations would have to be carried out on vanilla-kv vs. aware-kv would be helpful to understand this better. Comments from Reviewable |
Review status: all files reviewed at latest revision, 8 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 110 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 8 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 88 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 8 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 88 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 8 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 110 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 8 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 110 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 9 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 50 [r3] (raw file):
Is there a third option where we are allowed to remove rows from parent table? If yes, it's something that we can't explicitly choose with the docs/RFCS/sql_interleaved_tables.md, line 110 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 9 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 50 [r3] (raw file):
|
Review status: all files reviewed at latest revision, 9 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 110 [r3] (raw file):
|
Review status: 0 of 1 files reviewed at latest revision, 8 unresolved discussions, some commit checks pending. docs/RFCS/sql_interleaved_tables.md, line 36 [r1] (raw file):
|
Review status: 0 of 1 files reviewed at latest revision, 12 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 27 [r4] (raw file):
Interleaving is useful even without joins: consider a table with a composite PK and one or more secondary indexes that share a prefix with the PK: docs/RFCS/sql_interleaved_tables.md, line 38 [r4] (raw file):
It feels error-prone to me to allow interleaving whenever the types match without actually specifying which columns are involved. I think I'd rather use syntax more like foreign key references to specify which columns are to be used, and return an error if the columns don't make up (a prefix of) the primary key. docs/RFCS/sql_interleaved_tables.md, line 42 [r4] (raw file):
Is there syntax for doing this in the docs/RFCS/sql_interleaved_tables.md, line 57 [r4] (raw file):
Will an Comments from Reviewable |
Review status: 0 of 1 files reviewed at latest revision, 13 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 86 [r4] (raw file):
109 is the largest integer that can be encoded in a single byte, but is there a reason to restrict ourselves to an integer here. Seems like you could encoded Comments from Reviewable |
Review status: 0 of 1 files reviewed at latest revision, 13 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 86 [r4] (raw file):
|
Okay, this is starting to settle down and I'd like to start on the impl. Is it ready to merge? Review status: 0 of 1 files reviewed at latest revision, 13 unresolved discussions, some commit checks pending. docs/RFCS/sql_interleaved_tables.md, line 27 [r4] (raw file):
|
Reviewed 1 of 1 files at r5. Comments from Reviewable |
Review status: all files reviewed at latest revision, 12 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 38 [r4] (raw file):
|
Review status: all files reviewed at latest revision, 12 unresolved discussions, all commit checks successful. docs/RFCS/sql_interleaved_tables.md, line 134 [r5] (raw file):
Comments from Reviewable |
Support interleaving the data for sql tables such that the rows alternate in the kv map. This allows a user to optimize reads on tables that are frequently joined. For cockroachdb#2972.
Review status: 0 of 1 files reviewed at latest revision, 12 unresolved discussions, some commit checks pending. docs/RFCS/sql_interleaved_tables.md, line 38 [r4] (raw file):
|
Support interleaving the data for sql tables such that the rows alternate in the
kv map. This allows a user to optimize reads on tables that are frequently
joined.
Rendered preview: Preview at https://github.com/paperstreet/cockroach/blob/rfc_interleaved/docs/RFCS/sql_interleaved_tables.md
This change is