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

executor/aggregate: convert int to decimal in sum #2694

Merged
merged 5 commits into from Jan 23, 2018

Conversation

AndreMouche
Copy link
Member

@ngaut
Copy link
Member

ngaut commented Jan 16, 2018

Why make the change?

@AndreMouche
Copy link
Member Author

This PR is used to fix this issue pingcap/tidb#5643

@AndreMouche
Copy link
Member Author

Performace test

1 tidb/3 tikv/1pd on one machine

table schema

desc testagg;
+-----------------+---------------+------+------+---------+-------+
| Field           | Type          | Null | Key  | Default | Extra |
+-----------------+---------------+------+------+---------+-------+
| a      | int(11)       | NO   | PRI  | NULL    |       |
| b       | int(11)       | NO   |      | NULL    |       |
| c       | int(11)       | NO   |      | NULL    |       |
| d       | int(11)       | NO   | PRI  | NULL    |       |

records count

select count(*) from testagg;
+----------+
| count(*) |
+----------+
|  6001215 |
+----------+
1 row in set (1.69 sec

test with master


mysql> select sum(a),sum(b),sum(d),sum(c) from testagg;
+-----------------+----------------+-------------------+----------------+
| sum(a) | sum(b) | sum(d) | sum(c) |
+-----------------+----------------+-------------------+----------------+
|  18005322964949 |   600229457837 |          18007100 |    30009691369 |
+-----------------+----------------+-------------------+----------------+
1 row in set (3.70 sec)

mysql> select sum(a),sum(b),sum(d),sum(c) from testagg;
+-----------------+----------------+-------------------+----------------+
| sum(a) | sum(b) | sum(d) | sum(c) |
+-----------------+----------------+-------------------+----------------+
|  18005322964949 |   600229457837 |          18007100 |    30009691369 |
+-----------------+----------------+-------------------+----------------+
1 row in set (3.62 sec)

mysql> select sum(a),sum(b),sum(d),sum(c) from testagg;
+-----------------+----------------+-------------------+----------------+
| sum(a) | sum(b) | sum(d) | sum(c) |
+-----------------+----------------+-------------------+----------------+
|  18005322964949 |   600229457837 |          18007100 |    30009691369 |
+-----------------+----------------+-------------------+----------------+
1 row in set (3.55 sec)

test with current branch

mysql> select sum(a),sum(b),sum(d),sum(c) from testagg;
+-----------------+----------------+-------------------+----------------+
| sum(a) | sum(b) | sum(d) | sum(c) |
+-----------------+----------------+-------------------+----------------+
|  18005322964949 |   600229457837 |          18007100 |    30009691369 |
+-----------------+----------------+-------------------+----------------+
1 row in set (3.70 sec)

mysql> select sum(a),sum(b),sum(d),sum(c) from testagg;
+-----------------+----------------+-------------------+----------------+
| sum(a) | sum(b) | sum(d) | sum(c) |
+-----------------+----------------+-------------------+----------------+
|  18005322964949 |   600229457837 |          18007100 |    30009691369 |
+-----------------+----------------+-------------------+----------------+
1 row in set (3.82 sec)

mysql> select sum(a),sum(b),sum(d),sum(c) from testagg;
+-----------------+----------------+-------------------+----------------+
| sum(a) | sum(b) | sum(d) | sum(c) |
+-----------------+----------------+-------------------+----------------+
|  18005322964949 |   600229457837 |          18007100 |    30009691369 |
+-----------------+----------------+-------------------+----------------+
1 row in set (3.80 sec)

@siddontang
Copy link
Contributor

performance reduces?

@AndreMouche
Copy link
Member Author

Yes, since the decimal's computation is slower than the integer @siddontang

@XuHuaiyu
Copy link
Contributor

LGTM

@AndreMouche
Copy link
Member Author

@BusyJay PTAL

@AndreMouche
Copy link
Member Author

@BusyJay @hicqu PTAL

Copy link
Member

@BusyJay BusyJay left a comment

Choose a reason for hiding this comment

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

LGTM

@AndreMouche AndreMouche merged commit aecb7ba into tikv:master Jan 23, 2018
@AndreMouche AndreMouche deleted the coprocess_agg_sum_int branch January 23, 2018 07:29
sticnarf pushed a commit to sticnarf/tikv that referenced this pull request Oct 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants