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) #6750

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.

Signed-off-by: gengliqi <gengliqiii@gmail.com>
Signed-off-by: gengliqi <gengliqiii@gmail.com>
Signed-off-by: gengliqi <gengliqiii@gmail.com>
@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
Copy link
Member Author

@ti-chi-bot: This cherry pick PR is for a release branch and has not yet been approved by release team.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick, it must first be approved by the collaborators.

AFTER it has been approved by collaborators, please ping the release team in a comment to request a cherry pick review.

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.

@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. do-not-merge/cherry-pick-not-approved size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-5.3 labels Feb 7, 2023
@gengliqi gengliqi closed this Feb 7, 2023
@gengliqi gengliqi reopened this Feb 7, 2023
@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
@ti-chi-bot ti-chi-bot closed this Dec 1, 2023
@ti-chi-bot
Copy link
Member Author

This pull request is closed because its related version has closed automatic cherry-picking.
If it's still needed, you can reopen it or just regenerate it using bot,
see:

https://prow.tidb.net/command-help#cherrypick
https://book.prow.tidb.net/#/plugins/cherrypicker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. status/LGT2 Indicates that a PR has LGTM 2. type/cherry-pick-for-release-5.3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants