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

docs: add support late materialization rfc #39654

Merged

Conversation

Lloyd-Pottiger
Copy link
Contributor

@Lloyd-Pottiger Lloyd-Pottiger commented Dec 6, 2022

Signed-off-by: Lloyd-Pottiger yan1579196623@gmail.com

What problem does this PR solve?

Issue Number: ref #40601

Problem Summary:

What is changed and how it works?

add a rfc for supporting late materialization

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot
Copy link
Member

ti-chi-bot commented Dec 6, 2022

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • breezewish
  • winoros

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

The full list of commands accepted by this bot can be found here.

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 6, 2022
@Lloyd-Pottiger
Copy link
Contributor Author

@ti-chi-bot
Copy link
Member

@Lloyd-Pottiger: GitHub didn't allow me to request PR reviews from the following users: JinheLin.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

/cc @fixdb @winoros @chrysan @flowbehappy @JinheLin @windtalker

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

docs/design/2022-12-06-support-late-materialization Outdated Show resolved Hide resolved
Comment on lines 37 to 38
- Read the needed data pack of rest columns on table t
- Run the filter `REGEXP_LIKE(col_str2, 'new\\*.\\*line')`
Copy link
Contributor

Choose a reason for hiding this comment

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

After filtering col_str1, why we read all the rest columns instead of only col_str2 column?

Copy link
Contributor Author

@Lloyd-Pottiger Lloyd-Pottiger Dec 8, 2022

Choose a reason for hiding this comment

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

Good point! The most direct reason is most other AP systems do not do like this. 😄 Maybe it is not worth doing that. We can have a try when having enough time.

Co-authored-by: xzhangxian1008 <xzhangxian@foxmail.com>
Copy link
Member

@winoros winoros left a comment

Choose a reason for hiding this comment

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

You missed .md suffix.

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@Lloyd-Pottiger
Copy link
Contributor Author

You missed .md suffix.

thanks, fixed

@elsa0520
Copy link
Contributor

elsa0520 commented Dec 8, 2022

It is recommended to write clearly the stage where TiDB selects late materialization predicates.

@Lloyd-Pottiger
Copy link
Contributor Author

It is recommended to write clearly the stage where TiDB selects late materialization predicates.

Since we need to use statistics, so maybe it can be work as a rule of CBO?

@elsa0520
Copy link
Contributor

elsa0520 commented Dec 9, 2022

There is no cost in logical rules. Your strategy needs to be executed after the statistics derivation is complete.

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>

Since we need statistics to calculate the selectivity of the filter conditions, so this algorithm should be executed in postOptimize phase.

Obviously, beacuse the selectivity of the filter conditions is accurate, and the algorithm is not optimal, we can not guarantee that the pushed down filter conditions are the best. In order to patch a workaround for performance degradation, we will add a optimizer hint `/*+ enable_late_materialization=false */` to disable optimizer to push down filter conditions.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't recommend add this specific hint, we will have a hint set variable that is applicable to almost all the variable. @Reminiscent

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you mean to add a variable rather than a hint? And then we can use set variable enable_late_materialization=false for each query?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes. see #18748

Copy link
Contributor Author

Choose a reason for hiding this comment

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

lgtm, I will revise the docs later.

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot
Copy link
Member

@flowbehappy: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

@Lloyd-Pottiger
Copy link
Contributor Author

@fixdb @elsa0520 any other comments about the design? Or I will try to implement it sooner.


Since we need statistics to calculate the selectivity of the filter conditions, so this algorithm should be executed in postOptimize phase.

Obviously, beacuse the selectivity of the filter conditions is accurate, and the algorithm is not optimal, we can not guarantee that the pushed down filter conditions are the best. In order to patch a workaround for performance degradation, we will add a variable `/*+ set_var(enable_late_materialization=false) */` to disable optimizer to push down filter conditions.
Copy link
Contributor

Choose a reason for hiding this comment

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

The set_var hint is not a GA hint ( It is developed by community and no document).
So if you want to set var, please 'set xxx=xxx'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

get, thanks

- Filter conditions that apply to the same column are either pushed down or not pushed down at all.
- The pushed down filter conditions should not contain too many columns.

The algorithm is:
Copy link
Contributor

Choose a reason for hiding this comment

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

It needs to be clearly stated in which optimizer phase this function is called. This is very important

Copy link
Contributor Author

Choose a reason for hiding this comment

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

postOptimize

mentioned in line 96

Since we need statistics to calculate the selectivity of the filter conditions, so this algorithm should be executed in postOptimize phase.

Signed-off-by: Lloyd-Pottiger <yan1579196623@gmail.com>
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Mar 16, 2023
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Mar 16, 2023
@breezewish
Copy link
Member

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 88d053c

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 16, 2023
@Lloyd-Pottiger
Copy link
Contributor Author

/retest-required

@wuhuizuo
Copy link
Contributor

/retest-required

@Lloyd-Pottiger

You should check the failed test cases first.

@Lloyd-Pottiger
Copy link
Contributor Author

/retest-required

1 similar comment
@Lloyd-Pottiger
Copy link
Contributor Author

/retest-required

@ti-chi-bot ti-chi-bot merged commit f832456 into pingcap:master Mar 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants