This weekend I rolled back my database from 5.7.10 to 5.6.28. In a test load of 27 million records with inserts of multi-writes, the MySQL 5.7.10 took 120 minutes to load this database. On the same machine, 5.6.28 took 40 minutes. This is a repeatable event. The test was done on a Windows 7 Professional machine having 64GB of memory. And it was done on a Server with Windows Serve 2012 R2 with 256 GB of memory.
This was not the only problem. The group by statement fails to operate on a sub query and always operates on the table inside the query. Example:
select * from (select * from tablename order by datex desc, timex desc ) as A
group by recordx;
This query should pull the first record of the A Table as in 5.6.28. In 5.70.10, the query pulls out the earliest record entered from tablename and NOT A. Even when desc is replaced with asc, the result is the same.
5.6.28 always picks up the top element in the "A" table of the subquery.
MySQL needs some explaining to do with respect to their claim of 5.7.10 being 3x faster. It is definitely not backward compatible either as demonstrated by the "group by" behaviour.
MySQL 5.7 is 3x faster than MySQL 5.6, delivering 1.6 Million SQL Queries Per Second.
MySQL 8.0 should perform better and shows to be more efficient during benchmarking. It performs very well for read/write Workload versus MySQL 5.7. There's no reason not to use MySQL 8.0 if you're able to upgrade. Please see the following documentation for an in-depth look into MySQL 8.0.
So if you are using one user for your client, it won't be a problem and is more secure than the previous versions. Since MySQL leverages the most up-to-date hardware and software, it changes its default variables. You can read here for more details. Overall, MySQL 8.0 has dominated MySQL 5.7 efficiently.
This answer does not address the performance issue (I think more information is needed and that should be a separate question. It addresses the query issue.
MySQL documentation is quite explicit that this query:
select *
from (select * from tablename order by datex desc, timex desc ) as A
group by recordx
produces indeterminate results. Here is the relevant quote:
The server is free to choose any value from each group, so unless they are the same, the values chosen are indeterminate. Furthermore, the selection of values from each group cannot be influenced by adding an
ORDER BY
clause. Result set sorting occurs after values have been chosen, andORDER BY
does not affect which values within each group the server chooses.
It is a shame that your developers used code that is explicitly documented not to work correctly. You should fix the code.
One fix is:
select *
from tablename
where not exists (select 1
from tablename t2
where t2.recordx = t.recordx and
(t2.datex > t.datex or
t2.datex = t.datex and t2.timex > t.timex
)
);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With