Skip to content
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

Merged
merged 1 commit into from
Feb 28, 2022

Conversation

Jackie-Jiang
Copy link
Contributor

No description provided.

@@ -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();
Copy link
Contributor Author

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();
Copy link
Contributor Author

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);
Copy link
Contributor Author

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-commenter
Copy link

Codecov Report

Merging #8263 (51d69de) into master (e6330bb) will decrease coverage by 49.88%.
The diff coverage is 45.76%.

❗ Current head 51d69de differs from pull request most recent head 90a53d8. Consider uploading reports for the commit 90a53d8 to get more accurate results

Impacted file tree graph

@@              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     
Flag Coverage Δ
unittests1 ?
unittests2 14.17% <45.76%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ache/pinot/common/metadata/ZKMetadataProvider.java 0.00% <0.00%> (-20.15%) ⬇️
...g/apache/pinot/common/utils/helix/HelixHelper.java 0.00% <0.00%> (-16.02%) ⬇️
.../org/apache/pinot/core/plan/SelectionPlanNode.java 0.00% <0.00%> (-100.00%) ⬇️
...er/api/resources/PinotInstanceRestletResource.java 51.48% <50.00%> (-4.08%) ⬇️
...e/pinot/broker/broker/helix/BaseBrokerStarter.java 72.58% <77.77%> (+0.69%) ⬆️
...ntroller/helix/core/PinotHelixResourceManager.java 63.31% <82.55%> (+1.12%) ⬆️
.../controller/helix/ControllerRequestURLBuilder.java 74.41% <100.00%> (+0.40%) ⬆️
...ain/java/org/apache/pinot/core/data/table/Key.java 0.00% <0.00%> (-100.00%) ⬇️
.../java/org/apache/pinot/spi/utils/BooleanUtils.java 0.00% <0.00%> (-100.00%) ⬇️
.../java/org/apache/pinot/core/data/table/Record.java 0.00% <0.00%> (-100.00%) ⬇️
... and 1095 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e6330bb...90a53d8. Read the comment docs.

@Jackie-Jiang Jackie-Jiang merged commit 9c1a490 into apache:master Feb 28, 2022
@Jackie-Jiang Jackie-Jiang deleted the order_by_all_sorted branch February 28, 2022 21:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants