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

planner: allow queries on virtual columns to use index #10802

Closed
wants to merge 29 commits into from

Conversation

qw4990
Copy link
Contributor

@qw4990 qw4990 commented Jun 13, 2019

What problem does this PR solve?

Fix #5189, allow queries on virtual columns to use index.

What is changed and how it works?

Before this PR, virtual columns are replaced with corresponding physical columns when building the basic logical plan, which happens before the optimization.

Therefore, when the optimizer gets the replaced logical plan, there is no virtual column in it, so the optimizer will not use the corresponding virtual index to optimize this plan.

In this PR, we postpone replacing the virtual column until the optimization is finished, so the optimizer will take virtual columns into account and virtual indices will be used.

Check List

Tests

  • Unit test

@qw4990 qw4990 added the sig/planner SIG: Planner label Jun 13, 2019
@codecov
Copy link

codecov bot commented Jun 13, 2019

Codecov Report

Merging #10802 into master will decrease coverage by 0.0052%.
The diff coverage is 73.7931%.

@@               Coverage Diff                @@
##             master     #10802        +/-   ##
================================================
- Coverage   81.2832%   81.2779%   -0.0053%     
================================================
  Files           424        424                
  Lines         91004      91096        +92     
================================================
+ Hits          73971      74041        +70     
- Misses        11704      11726        +22     
  Partials       5329       5329

planner/core/logical_plan_builder.go Outdated Show resolved Hide resolved
planner/core/find_best_task.go Outdated Show resolved Hide resolved
@qw4990
Copy link
Contributor Author

qw4990 commented Jun 26, 2019

/run-all-tests

@qw4990 qw4990 requested a review from eurekaka June 26, 2019 05:13
@qw4990
Copy link
Contributor Author

qw4990 commented Jun 26, 2019

@qw4990
Copy link
Contributor Author

qw4990 commented Jul 1, 2019

PTAL @lamxTyler @winoros @crazycs520

planner/core/cbo_test.go Outdated Show resolved Hide resolved
planner/core/cbo_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alivxxx alivxxx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

planner/core/find_best_task.go Outdated Show resolved Hide resolved
planner/core/find_best_task.go Outdated Show resolved Hide resolved
planner/core/find_best_task.go Show resolved Hide resolved
planner/core/find_best_task.go Outdated Show resolved Hide resolved
@qw4990 qw4990 force-pushed the vc branch 2 times, most recently from d8d83a6 to ccd39b0 Compare July 29, 2019 12:55
fmt

fixup

fixup

refmt

add UT
@qw4990
Copy link
Contributor Author

qw4990 commented Aug 2, 2019

Some new problems and corner cases are found when a virtual column is in the inner child of an IndexJoin or an IndexLookup, which are hard to fix since it will make our code weird and hard to maintain.
Therefore we decide to close this PR and fix this virtual column problem after finishing our cascades planner.

@qw4990 qw4990 closed this Aug 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner status/LGT2 Indicates that a PR has LGTM 2. type/enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support add index for a virtual generated column
9 participants