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

Use size of filtered column to reserve memory for filter when result_size_hint < 0 (#6746) #6753

Merged

Conversation

ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #6746

What problem does this PR solve?

Issue Number: close #6730

Problem Summary:
See #6730

What is changed and how it works?

If result_size_hint < 0, filter makes reserve using size of filtered column, not source column.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code
/// c is a string that is not equal to every b in table.
mysql> create table oom(a bigint, b varchar(200), c char(200));
Query OK, 0 rows affected (0.09 sec)

mysql> select count(*) from oom;
+----------+
| count(*) |
+----------+
|    60000 |
+----------+
1 row in set (0.02 sec)

mysql> alter table oom set tiflash replica 1;
Query OK, 0 rows affected (0.09 sec)

mysql> explain select * from oom o1 where (a,b,c) not in (select a,b,c from oom o2);
+--------------------------------------+----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------+
| id                                   | estRows  | task         | access object | operator info                                                                                                           |
+--------------------------------------+----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------+
| TableReader_27                       | 48000.00 | root         |               | MppVersion: 1, data:ExchangeSender_26                                                                                   |
| └─ExchangeSender_26                  | 48000.00 | mpp[tiflash] |               | ExchangeType: PassThrough                                                                                               |
|   └─HashJoin_25                      | 48000.00 | mpp[tiflash] |               | CARTESIAN anti semi join, other cond:eq(test.oom.a, test.oom.a), eq(test.oom.b, test.oom.b), eq(test.oom.c, test.oom.c) |
|     ├─ExchangeReceiver_14(Build)     | 60000.00 | mpp[tiflash] |               |                                                                                                                         |
|     │ └─ExchangeSender_13            | 60000.00 | mpp[tiflash] |               | ExchangeType: Broadcast                                                                                                 |
|     │   └─TableFullScan_12           | 60000.00 | mpp[tiflash] | table:o2      | keep order:false                                                                                                        |
|     └─TableFullScan_11(Probe)        | 60000.00 | mpp[tiflash] | table:o1      | keep order:false                                                                                                        |
+--------------------------------------+----------+--------------+---------------+-------------------------------------------------------------------------------------------------------------------------+
7 rows in set (0.00 sec)

In master, this sql can reach 20GiB+ memory and OOM on my laptop.
After this patch, this sql can run successfully and the max memory is about 500MiB.

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

Fix the issue that CARTESIAN semi join may use larger memory than expected.

@ti-chi-bot
Copy link
Member Author

ti-chi-bot commented Feb 7, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • LittleFall
  • gengliqi

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 do-not-merge/cherry-pick-not-approved release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR. labels Feb 7, 2023
@gengliqi gengliqi requested review from gengliqi and removed request for gengliqi February 7, 2023 07:19
@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 7, 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 Feb 7, 2023
@VelocityLight VelocityLight added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Feb 27, 2023
@gengliqi
Copy link
Contributor

gengliqi commented Mar 3, 2023

/merge

@ti-chi-bot
Copy link
Member Author

@gengliqi: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

You only need to trigger /merge once, and if the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes.

If you have any questions about the PR merge process, please refer to pr process.

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.

@ti-chi-bot
Copy link
Member Author

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

Commit hash: afc0556

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Mar 3, 2023
@ti-chi-bot ti-chi-bot merged commit 26800c3 into pingcap:release-6.5 Mar 3, 2023
@VelocityLight VelocityLight added do-not-merge/cherry-pick-not-approved cherry-pick-approved Cherry pick PR approved by release team. and removed cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/cherry-pick-not-approved labels Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 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. type/cherry-pick-for-release-6.5 This PR is cherry-picked to release-6.5 from a source PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants