-
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
sql: GetRequest not used when querying secondary index without stored columns #72735
Comments
Removing the |
This was added by b852e92. I don't know why, author and primary reviewer are both gone (Rohan and Solon). @RaduBerinde @postamar and @jordanlewis any ideas why CanSplitSpanIntoFamilySpans would return false when the index doesn't store any columns? |
No, I don't understand why that condition is there either. I can't think of any circumstance where a secondary index without stored columns would behave differently in this case. @rohany I'm pinging you since I know you are around on our GitHub from time to time - if you happen to see this and have any recollection of why this condition was there that would be great but it's no big deal either way! Hope you are doing well :) In some cases, we have to be careful to scan all column families because queries that are just looking for "row existence" can't rely on any given column family to be there - any column family might be. There's a sentinel key concept for this, as well. I think this only really matters for the primary index, though. I'll think some more about this, but we could put up a PR with the condition removed and see if tests pass at least. |
Hey, nice to hear from you! I believe the original intention of that code was pretty explicit for the original use case -- we can't split a secondary index into separate families if the index isn't storing any columns. Nathan's use case seems valid, where family 0 can be the target of a |
Informs cockroachdb#72735 Release note: None
Informs cockroachdb#72735 Release note: None
72794: sql: allow point lookups on secondary indexes with 0 stored columns r=cucaroach a=cucaroach Remove an unnecessary check that was preventing point lookups in some TPCE queries. Fixes #72735 Release note: None Co-authored-by: Tommy Reilly <[email protected]>
In #61583, @jordanlewis landed a major improvement to perform point KV
GetRequests
over ranged KVScanRequests
in some cases. This came with a number of benefits, which were listed in the PR description.While looking at TPC-E, I've seen traces that indicate that this optimization has had a very positive impact. However, I've also noticed a few cases where point lookups should be used when querying secondary indexes, but aren't being used. In these cases, we're resorting to
Scan
requests instead ofGet
requests.I believe I've narrowed this down to some logic in
span.Builder.CanSplitSpanIntoFamilySpans
, which may be too restrictive:cockroach/pkg/sql/span/span_builder.go
Lines 269 to 290 in 13669f9
Specifically, I think there's something off with this
NumSecondaryStoredColumns
check. I don't understand why it's needed, and it seems to break cases where a unique secondary index that does not store any columns is being queried to retrieve the primary key column(s).Here's a reproduction:
The text was updated successfully, but these errors were encountered: