-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Bugfix for order-by all sorted optimization #8263
Conversation
02eb83d
to
90a53d8
Compare
@@ -56,14 +56,16 @@ public SelectionPlanNode(IndexSegment indexSegment, QueryContext queryContext) { | |||
if (orderByExpressions == null) { | |||
// Selection only | |||
TransformOperator transformOperator = new TransformPlanNode(_indexSegment, _queryContext, expressions, | |||
Math.min(limit + _queryContext.getOffset(), DocIdSetPlanNode.MAX_DOC_PER_CALL)).run(); | |||
Math.min(limit, DocIdSetPlanNode.MAX_DOC_PER_CALL)).run(); |
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.
Without order-by, should scan limit
records
if (isAllOrderByColumnsSorted(orderByExpressions)) { | ||
// All order-by columns are sorted, no need to sort the records | ||
TransformOperator transformOperator = new TransformPlanNode(_indexSegment, _queryContext, expressions, | ||
Math.min(limit + _queryContext.getOffset(), DocIdSetPlanNode.MAX_DOC_PER_CALL)).run(); |
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.
With order-by, should scan limit + offset
records
@@ -101,14 +103,12 @@ public SelectionPlanNode(IndexSegment indexSegment, QueryContext queryContext) { | |||
* @return true is all columns in order by clause are sorted . False otherwise | |||
*/ | |||
private boolean isAllOrderByColumnsSorted(List<OrderByExpressionContext> orderByExpressions) { | |||
int numOrderByExpressions = orderByExpressions.size(); | |||
for (int i = 0; i < numOrderByExpressions; i++) { | |||
OrderByExpressionContext expressionContext = orderByExpressions.get(0); |
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.
orderByExpressions.get(0)
is wrong, and can cause false positive
Codecov Report
@@ Coverage Diff @@
## master #8263 +/- ##
=============================================
- Coverage 64.06% 14.17% -49.89%
+ Complexity 4246 81 -4165
=============================================
Files 1586 1586
Lines 83399 83547 +148
Branches 12641 12667 +26
=============================================
- Hits 53427 11842 -41585
- Misses 26129 70817 +44688
+ Partials 3843 888 -2955
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
No description provided.