I have the following Mysql query
explain SELECT count(*) as assetCount
FROM MdhRawAsset m
where sysCreationDate > date_add(now(), INTERVAL -1 DAY)
AND sysCreationDate <= now()
AND itemType = 'TS';
Results :
| id | select_type | table | type |possible_keys
| 1 | SIMPLE | m | range | MdhRawAsset_on_sysCreationDate, MdhRawAsset_itemType
---------------------------------------------------------------------
|Key |Key_len | ref | rows | Extra |
MdhRawAsset_on_sysCreationDate| 8 | NULL | 53269 | Using where |
Questions :
MdhRawAsset contains 37.5 million of data, is there a better way to write this query ?The execution time of a query depends on too many issues to determine how long it will take. The load on the server, the number of rows, etc. The best you can do is run it in a typical load and see how long it takes.
You seem to have the correct indexes set up, so I do not see a better way to optimize, but someone else may know better than I do.
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