[MDEV-3745] LP:1008334 - Benchmark Query 4x Faster on MySQL 5.5 Created: 2012-06-04 Updated: 2015-02-02 Resolved: 2012-10-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Bug | ||
| Reporter: | Brian Boatright (Inactive) | Assignee: | Vladislav Vaintroub |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | Launchpad | ||
| Attachments: |
|
| Description |
|
Running this query is almost four times faster on MySQL than the same version of MariaDB. SELECT BENCHMARK(10000000,DATE_SUB(FROM_UNIXTIME(RAND() * 2147483648), INTERVAL (FLOOR(1 + RAND() * 365)) DAY)); Results on Workstation Win7 x64 16gb i7 3ghz
Results on Server Win2k8 R2 x64 8gb Xeon 1270 3.4ghz
Results on older server running Win2k3 x32 4gb Xeon 5050 3ghz
Is there any reason this query would be running so much slower on MariaDB vs MySQL? |
| Comments |
| Comment by Elena Stepanova [ 2012-06-06 ] |
|
Re: Benchmark Query 4x Faster on MySQL 5.5 MariaDB 5.5.24: ~25 sec |
| Comment by Vladislav Vaintroub [ 2012-06-07 ] |
|
Re: Benchmark Query 4x Faster on MySQL 5.5 If this is out-of-curiousity, the explanation is this: MariaDB implemented microseconds precision for temporal datatypes. In the past, internal representation of temporal datatypes was 64 bit integer. Now, it is decimal. Decimals are slower than integers in many scenarios . Now, there are still some optimizations to speed up datetimes and avoid decimals in different scenarios. For example, FROM_UNIXTIME understands that its parameter is integer and does not do decimal arithmetic in this case. In your example, FROM_UNIXTIME gets a double parameter and thus needs to be converted into decimal. Thus, you can speed up your query by roughly 50%, if you rewrite it as BENCHMARK(10000000,DATE_SUB(FROM_UNIXTIME(FLOOR(RAND() * 2147483648)), INTERVAL (FLOOR(1 + RAND() * 365)) DAY)) Note the FROM_UNIXTIME(FLOOR(...)), FLOOR was not there in original query. |
| Comment by Brian Boatright (Inactive) [ 2012-06-07 ] |
|
Re: Benchmark Query 4x Faster on MySQL 5.5 With your new query forcing a integer result from RAND it is still much slower than MySQL but is faster overall. Results for new query from my workstation:
I would think as a general rule that any query would run at least the same speed if not faster. Even with the FLOOR RAND it it still slower by a significant amount. |
| Comment by Rasmus Johansson (Inactive) [ 2012-06-27 ] |
|
Launchpad bug id: 1008334 |