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

memory.reArrangeFallback uses 50% of the time for SELECT with 8k partitions #30353

Closed
mjonss opened this issue Dec 2, 2021 · 0 comments · Fixed by #30414
Closed

memory.reArrangeFallback uses 50% of the time for SELECT with 8k partitions #30353

mjonss opened this issue Dec 2, 2021 · 0 comments · Fixed by #30414
Assignees
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@mjonss
Copy link
Contributor

mjonss commented Dec 2, 2021

Bug Report

Profiling a simple SELECT * FROM t for a partitioned table with maximum number of partitions spends around half the time in the memory.reArrangeFallback tracking function.

1. Minimal reproduce step (Required)

create table tp (a int primary key, b varchar(255)) partition by hash (a) partitions 8192;
insert into tp values (1, 'row with id 1, partition p1 filler data'), (2, 'partition p2, filler data for row with id 2'), (9, 'filler data for row with id 9, partition p9');
-- start profiling and run this over and over again for profiling:
select * from tp;

2. What did you expect to see? (Required)

The result to be given within milliseconds at least (MySQL does it in 0.1 second)

mysql> create table tp (a int primary key, b varchar(255)) partition by hash (a) partitions 8192;
Query OK, 0 rows affected (1 min 10,58 sec)

mysql> insert into tp values (1, 'row with id 1, partition p1 filler data'), (2, 'partition p2, filler data for row with id 2'), (9, 'filler data for row with id 9, partition p9');
Query OK, 3 rows affected (0,57 sec)
Records: 3  Duplicates: 0  Warnings: 0

mysql> select * from tp;
+---+---------------------------------------------+
| a | b                                           |
+---+---------------------------------------------+
| 1 | row with id 1, partition p1 filler data     |
| 2 | partition p2, filler data for row with id 2 |
| 9 | filler data for row with id 9, partition p9 |
+---+---------------------------------------------+
3 rows in set (0,11 sec)

3. What did you see instead (Required)

The SELECT query took 1 second

tidb> create table tp (a int primary key, b varchar(255)) partition by hash (a) partitions 8192;
Query OK, 0 rows affected (0,16 sec)

tidb> insert into tp values (1, 'row with id 1, partition p1 filler data'), (2, 'partition p2, filler data for row with id 2'), (9, 'filler data for row with id 9, partition p9');
Query OK, 3 rows affected (0,00 sec)
Records: 3  Duplicates: 0  Warnings: 0

tidb> select * from tp;
+---+---------------------------------------------+
| a | b                                           |
+---+---------------------------------------------+
| 1 | row with id 1, partition p1 filler data     |
| 2 | partition p2, filler data for row with id 2 |
| 9 | filler data for row with id 9, partition p9 |
+---+---------------------------------------------+
3 rows in set (1,01 sec)

4. What is your TiDB version? (Required)

Release Version: v5.4.0-alpha-289-g92c7c075d5
Edition: Community
Git Commit Hash: 92c7c075d502f81af2298582f66533bc23cb3d53
Git Branch: master
UTC Build Time: 2021-12-01 12:29:27
GoVersion: go1.17
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false 

Profiles:
reArrangeFallback-profile-flamegraph
reArrangeFallback-Profile-Top

@mjonss mjonss added the type/bug The issue is confirmed as a bug. label Dec 2, 2021
@aytrack aytrack added severity/major sig/sql-infra SIG: SQL Infra sig/execution SIG execution and removed sig/sql-infra SIG: SQL Infra labels Dec 3, 2021
@wshwsh12 wshwsh12 added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Dec 6, 2021
@wshwsh12 wshwsh12 self-assigned this Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants