-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Range Query Optimization (For sequential Vindex types) #17342
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: c-r-dev <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
I unchecked this, because CI has not yet run
|
thanks, confirm - modified tests passed consistently locally ( i have run module level unit tests )
Didn't get CI to run locally end to end. Currently working on the CI setup. |
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.
Thank you so much for your contribution!
This looks really good from my POV.
I would love to see a plan test and and one end-to-end test as well. Not sure where the end-to-end test should live. @harshit-gangal probably knows.
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 add plan test that uses Between for Sequential Vindex and Non-Sequential Vindex type
It can be added to go/vt/vtgate/planbuilder/testdata/select_cases.json
thanks @systay and @harshit-gangal for reviewing and sharing feedback, let me incorporate these and get back. Will reach out in case of questions. |
… feedback Signed-off-by: c-r-dev <[email protected]>
Signed-off-by: c-r-dev <[email protected]>
…ema files) Signed-off-by: c-r-dev <[email protected]>
Thanks for the suggestion and pointing me to sample , i have added new test cases with e8593a8 |
@@ -948,6 +948,61 @@ | |||
] | |||
} | |||
} | |||
}, | |||
"sequential": { |
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.
not sure, but I'm thinking we could use an existing keyspace instead of adding a new one. feel free to add a vindex or even a table if you need to.
I'm just thinking of not adding unnecessary complexity if we don't have to
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.
sure thing , incorporated with 5a7c8f1 , using user
keyspace - added extra vindex and table
] | ||
} | ||
}, | ||
{ |
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.
nice set of planner tests. could you add at least one test where the values in the between are not literal values, but instead columns from another table. something like:
select *
from tblA
join tblB on tblA.foo = tbl.bar
where tblA.X between tblB.C and tblB.D
it'd be good to make sure that this also works as expected.
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.
thanks for suggesting this , added a test case now 0697cb0 , and also fixed missing Cost for RoutOpCode.Between
.
go/vt/vtgate/vindexes/binary_test.go
Outdated
if !assert.Equal(t, got[0].String(), want) { | ||
t.Errorf("RangeMap(): %+v, want %+v", got, want) | ||
} |
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.
if !assert.Equal(t, got[0].String(), want) { | |
t.Errorf("RangeMap(): %+v, want %+v", got, want) | |
} | |
assert.Equal(t, want, got[0].String()) |
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.
thanks , done with 5a7c8f1
"Query": "select cola, colb, col1 from seq_multicol_tbl where cola between 1 and 5", | ||
"Table": "seq_multicol_tbl", | ||
"Values": [ | ||
"(1, 5)" |
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.
I don't understand why we get the values field here for a Scatter
route. it doesn't look right
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.
thanks for catching this , noticed processSingleColumnVindex
has few extra early checks compared to processMultiColumnVindex
. With 8a0ded0 , added checks for vindex and also routingCode before processing any futher.
This ensures Values
is not set in case of Scatter
route.
Please help to review if addition of these checks has any other side effects (which i may have missed) , ensured all test cases are passing.
thanks @systay , will check these and make next set of changes. |
Signed-off-by: c-r-dev <[email protected]>
…ar to processSingleColumnVindex) Signed-off-by: c-r-dev <[email protected]>
Signed-off-by: c-r-dev <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17342 +/- ##
==========================================
- Coverage 67.52% 67.51% -0.01%
==========================================
Files 1581 1581
Lines 253948 254030 +82
==========================================
+ Hits 171480 171520 +40
- Misses 82468 82510 +42 ☔ View full report in Codecov by Sentry. |
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.
Changes looks good.
For end to end test. We recently added a way to test the plan tests to also run as e2e test
Look here https://github.com/vitessio/vitess/blob/main/go/test/endtoend/vtgate/plan_tests/plan_e2e_test.go
and the PR that added it #17117
You would have to add filter_cases.json
to the e2e test.
thanks @harshit-gangal , will pull in the changes from #17117 and add test case for |
Thanks , added end-to-end test case for |
}, | ||
"skip_e2e":true | ||
} |
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.
new test should not be skipped
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.
thanks , out of the 5 new test cases added for between
, marked the final one related to join as skip_e2e.
Reason for marking this skip , is because of "OperatorType": "Join" , verifyTestExpectations for join
cases verifies -> Verify that the Join primitive sees atleast 1 row on the left side. Currently we don't have any sample data in these test schema tables. (pls let me know if we can put some test data in these tables for e2e testing)
@harshit-gangal please help to let me know if I have missed any thing , or if there is a better way to write this test for "Between clause on a binary vindex field with values from a different table"
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 need to add the sample data to have data on left and right side of the join.
The policy after adding these plan test is that we need to ensure that new tests does not add skip_e2e
flag.
For that we have to keep modifying the sample input data.
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.
thanks @harshit-gangal , added sample data loading with 1400fea , and removed skip_e2e
. All new tests are passing with out skipping.
Please help to review.
thanks @harshit-gangal for reviewing , will incorporate feedback and share and updated version for review. |
Signed-off-by: c-r-dev <[email protected]>
@systay , thanks for the feedback , have worked with @harshit-gangal and got Can you please help to review when you get a chance. |
Description
Queries that specify values in a range (for vindexed column) are sent to all shards, instead of just the shards which contain the values in the range.
Related Issue(s)
Fixes #9808
Checklist
Deployment Notes
Made the change for sequential Vindexes (
binary
andnumeric
)Tests Performed
Added unit tests module level
Included sample schema with two columns (c1 and c2) , c1 is vindexed (type binday) and c2 is not vindexed.
When range queried on column
c1
(vindex column) :When range queried on column
c2
(non vindex column) :