You are here
MySQL single query performance - the truth!
MySQL single query performance - the truth!
As suggested by morgo I did a little test for the same query and the same data-set mentioned in Impact of column types on MySQL JOIN performance but looking into an other dimension: the time (aka MySQL versions).
The answer
To make it short. As a good consultant the answer must be: "It depends!" :-)
The test
The query was again the following:
SELECT * FROM a JOIN b ON b.a_id = a.id WHERE a.id BETWEEN 10000 AND 15000 ;
The Query Execution Plan was the same for all tested releases.
The relevant MySQL variables where used as follows where possible. Should I have considered join buffer, or any other of those local per session buffers (read_buffer_size
, read_rnd_buffer_size
, join_buffer_size
)?
innodb_buffer_pool_size = 768M innodb_buffer_pool_instances = 1 innodb_file_per_table = 1
The results
mysql-4.0.30 | mysql-4.1.25 | mysql-5.0.96 | mysql-5.1.73 | mysql-5.5.35 | mysql-5.6.15 | mysql-5.7.3 | |
---|---|---|---|---|---|---|---|
AVG | 40.86 | 38.68 | 3.71 | 4.69 | 4.64 | 7.22 | 6.05 |
MEDIAN | 41.07 | 38.13 | 3.69 | 4.46 | 4.65 | 6.32 | 6.05 |
STDEV | 1.51 | 2.26 | 0.06 | 0.34 | 0.03 | 2.21 | 0.03 |
MIN | 39.27 | 36.99 | 3.67 | 4.40 | 4.59 | 6.26 | 6.02 |
MAX | 44.11 | 44.45 | 3.86 | 5.23 | 4.67 | 13.16 | 6.10 |
COUNT | 10.00 | 10.00 | 10.00 | 10.00 | 10.00 | 10.00 | 10.00 |
mariadb-5.1.44 | mariadb-5.2.10 | mariadb-5.3.3 | mariadb-5.5.34 | mariadb-10.0.6 | |
---|---|---|---|---|---|
AVG | 4.58 | 8.63 | 8.34 | 5.02 | 6.12 |
MEDIAN | 4.58 | 7.97 | 8.01 | 5.02 | 6.01 |
STDEV | 0.01 | 1.45 | 1.10 | 0.02 | 0.25 |
MIN | 4.55 | 7.86 | 7.90 | 4.99 | 5.97 |
MAX | 4.60 | 11.38 | 11.46 | 5.06 | 6.75 |
COUNT | 10.00 | 10.00 | 10.00 | 10.00 | 10.00 |
percona-5.0.92-23.85 | percona-5.1.72-14.10 | percona-5.5.34-32.0 | percona-5.6.14-62.0 | |
---|---|---|---|---|
AVG | 3.79 | 4.70 | 4.94 | 10.53 |
MEDIAN | 3.79 | 4.70 | 4.89 | 12.41 |
STDEV | 0.02 | 0.03 | 0.14 | 3.35 |
MIN | 3.76 | 4.67 | 4.86 | 5.68 |
MAX | 3.83 | 4.75 | 5.34 | 12.93 |
COUNT | 10.00 | 10.00 | 10.00 | 10.00 |
galera-5.5.33-23.7.6 / 2.7 | |
---|---|
AVG | 4.31 |
MEDIAN | 3.98 |
STDEV | 1.18 |
MIN | 3.76 |
MAX | 8.54 |
COUNT | 30.00 |
The Graph
Conclusion
Do not trust benchmarks. They are mostly worthless for your specific workload and pure marketing buzz... Including the one above! ;-)
Database vendors (Oracle/MySQL, Percona, MariaDB) are primarily focussing on throughput and features. In general this is at the costs of single query performance.
MySQL users like Facebook, LinkedIn, Google, Wikpedia, Booking.com, Yahoo! etc. are more interested in throughput than single query performance (so I assume). But most of the MySQL users (95%) do not have a troughput problem but a single query performance problem (I assume here that this is true also for Oracle, MS-SQL Server, DB2, PostgreSQL, etc.).
So database vendors are not primarily producing for the masses but for some specific users/customers (which possibly pay a hell of money for this).
Back to the data:
My first hypothesis: "The old times were always better" is definitely not true. MySQL 4.0 and 4.1 sucked with this specific query. But since MySQL 5.0 the rough trend is: single query performance becomes worse over time (newer versions). I assume this also true for other databases...
Some claims like: "We have the fastest MySQL" or "We have hired the whole optimizer team" does not necessary reflect in better single query performance. At least not for this specific query.
So in short: If you upgrade or sidegrade (MySQL <-> Percona <-> MariaDB), test always very carefully! It is not predictable where the traps are. Newer MySQL release can increase performance of your application or not. Do not trust marketing buzz!
Artefacts
Some artefacts we have already found during this tiny test:
- In MySQL 5.0 an optimization was introduced (not in the Optimizer!?!) to speed up this specific query dramatically.
- MariaDB 5.2 and 5.3 were bad for this specific query.
- I have no clue why Galera Cluster has shown the best results for 5.5. It is no intention or manipulation! It is poor luck. But I like it! :-)
- MySQL 5.6 seems to have some problems with this query. To much improvement done by Oracle/MySQL?
- Percona 5.6 sometimes behaves much better with this query than normal MySQL but from time to time something kicks in which makes Percona dramatically slower. Thus the bad results. I have no clue why. I first though about an external influence. But I was capable to reproduce this behaviour (once). So I assume it must be something Percona internally (AHI for example?).
Finally
Do not shoot the messenger!
If you want to reproduce the results most information about are already published. If something is missing please let me know.
Please let me know when you do not agree with the results. So I can expand my universe a bit...
It was fun doing this tests today! And MyEnv was a great assistance doing this kind of tests!
If you want us to do such test for you, please let us know. Our consulting team would be happy to assist you with upgrading or sidegrading problems.
- Shinguz's blog
- Log in or register to post comments
Comments
Love it!
Love is all around...
Do not trust benchmarks
Validate things
Hello Stephane,
Sorry, I cannot completely follow you what you want me to do. But please feel free to reproduce. All needed information are available I think!
Oli
Confidence
95%?
throughput vs single query performance
Hi Massimo,
From my last 14 years experience as DBA and DB consultant (Oracle, MySQL, MS-SQL Server, PostgreSQL). I have seen several hundreds? different DB performance problems in these years and only few of them (1 upon 20? or even less) where real throughput problems.
Most of them where single query performance problems (including optimizer/optimizing and configuration problems).
Regards,
Oli
Performance problems
Majority of MySQL users has no performance problem!
Hello Øystein,
Unfortunately I have to agree! MySQL is damn fast/cool and hardware nowadays as well. And having much RAM and fast multi-core CPU's sucks from a tuner point of view ;-)
ot theses statisticians...
Hello Øystein,
The high/bad standard deviation with MySQL 5.6 comes from some very high outlier in the beginning of the test. I did not delete this outlier because I have seen this as an unfair treatment to the other releases which did not show this phenomena.
I dropped the first measurement always (memory heat-up).
And I did all the test series in the same way. So more or less same fair/unfair for all releases.
By ignoring the outlier you still can see around 5% changes in performance.
About statistics: I never understood these guys. But my feeling tells me that in measurement 4 to 11 5.7 is sligthly faster than 5.6. Possibly not significant but sligthly and measureable...
And in parctice. I understand your skipping of 10 queries before measuring. But how realistic is this in real DB life? The first shot must be fast...
Measurements
System restart vs query start