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

feature: Support field function substring optimization #466

Open
1 task
haitaoguan opened this issue Sep 5, 2022 · 3 comments
Open
1 task

feature: Support field function substring optimization #466

haitaoguan opened this issue Sep 5, 2022 · 3 comments
Labels
A-feature feature with good idea B-performance B-SQL SQL layer C-stonedb-5.7 associated with stonedb 5.7

Comments

@haitaoguan
Copy link
Collaborator

haitaoguan commented Sep 5, 2022

Describe the problem

When you use a function on a field, performance is affected.The trace.log displays the message "Unoptimized expression near 'substr'".

###Abnormal
mysql> select sum(ce) from all_bak where year(xxxx)=2020;
+------------------+
| sum(ce)          |
+------------------+
| 1332849867555.84 |
+------------------+
1 row in set (4.67 sec)

###Normal
mysql> select sum(ce) from all_bak where xxxx between '2020-01-01' and '2020-12-31';
+------------------+
| sum(ce)          |
+------------------+
| 1332849867555.84 |
+------------------+
1 row in set (0.00 sec)

###Abnormal
mysql> select substring(a.h_m,1,4) hrd,sum(ce) from all_bak a group by substring(a.h_m,1,4);
+------+-----------------+
| hrd | sum(ce)         |
+------+-----------------+
| 7499 |  63816644743.20 |
| 7040 |  47191046107.84 |
| 8341 | 191566748484.48 |
| 7299 | 112803464512.32 |
| 8391 |  73260665137.28 |
| 6129 | 205524450576.96 |
| 7289 | 318319076069.28 |
| 7511 | 320367771924.48 |
+------+-----------------+
8 rows in set (22.44 sec)

###Normal
mysql> select h_m,sum(ce) from all_bak a group by h_m;
+-------+-----------------+
| h_m | sum(ce)         |
+-------+-----------------+
| 7499  |  63816644743.20 |
| 7040  |  47191046107.84 |
| 8341  | 191566748484.48 |
| 7299  | 112803464512.32 |
| 8391  |  73260665137.28 |
| 6129  | 205524450576.96 |
| 7289  | 318319076069.28 |
| 7511  | 320367771924.48 |
+-------+-----------------+
8 rows in set (5.45 sec)

Expected behavior

No response

How To Reproduce

No response

Environment

./mysqld --version

./mysqld Ver 5.7.36-StoneDB for Linux on x86_64 (build-)
build information as follow:
Repository address: git@github.com:stoneatom/stonedb.git:stonedb-5.7
Branch name: stonedb-5.7
Last commit ID: 05eb397
Last commit time: Date: Mon Aug 15 14:05:47 2022 +0800
Build time: Date: 2022年 08月 15日 星期一 15:38:53 CST

Are you interested in submitting a PR to solve the problem?

  • Yes, I will!
@haitaoguan haitaoguan added the A-bug Something isn't working label Sep 5, 2022
@adofsauron adofsauron self-assigned this Sep 7, 2022
@RingsC RingsC added prio: high High priority C-stonedb-5.7 associated with stonedb 5.7 labels Sep 7, 2022
@adofsauron
Copy link
Collaborator

What is the table structure? What is the statement for the amount of data inserted? What is the amount of data

@haitaoguan haitaoguan changed the title bug: StoneDB does not support function optimization. bug: StoneDB does not support substring function or year function optimization. Sep 8, 2022
hustjieke added a commit that referenced this issue Sep 17, 2022
…ead #472 (#422 #465 #466) (#472)

* Refactor the aggregation to multithread

Co-authored-by: hustjieke <gaoriyao1@gmail.com>
@isredstar
Copy link
Collaborator

image
So far,Tianmu doesn‘t support optimize function expression yet.

@hustjieke hustjieke changed the title bug: StoneDB does not support substring function or year function optimization. feature: StoneDB does not support substring function or year function optimization. Nov 16, 2022
@hustjieke hustjieke added A-feature feature with good idea and removed A-bug Something isn't working labels Nov 16, 2022
@adofsauron adofsauron added prio: low Low priority and removed prio: high High priority labels Dec 6, 2022
@adofsauron adofsauron added prio: high High priority and removed prio: low Low priority labels Dec 23, 2022
@adofsauron adofsauron changed the title feature: StoneDB does not support substring function or year function optimization. feature: Support field function optimization Dec 23, 2022
@adofsauron
Copy link
Collaborator

ACK

@adofsauron adofsauron changed the title feature: Support field function optimization feature: Support field function substring optimization Dec 26, 2022
@wisehead wisehead added this to the stonedb_5.7_v1.0.3 milestone Jan 13, 2023
@hustjieke hustjieke added B-storage data type, data storage, insert,update,delete, transactions and removed B-storage data type, data storage, insert,update,delete, transactions labels Jan 30, 2023
@wisehead wisehead removed the prio: high High priority label Apr 11, 2023
@adofsauron adofsauron removed their assignment Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-feature feature with good idea B-performance B-SQL SQL layer C-stonedb-5.7 associated with stonedb 5.7
Projects
None yet
Development

No branches or pull requests

6 participants