Reputation: 625
I have get the query in this thread Sum Multiple Row Date Difference Mysql
The problem now is that the query execution time is so long. I try with a little row data http://sqlfiddle.com/#!2/0d496/1/0. And it is like crazy thing when i try to execute this query in my local database (my table total row is about 200.000 row), because there is no result even when I wait in a very long time.
I want to ask, is this query by default need a long time to execute? Is it possible to make it faster? How? Thank you.
Upvotes: 1
Views: 188
Reputation: 1538
Try adding Speed to your index:
KEY LogCarIdx
(LogDate
,CarId
, Speed
)
Then the c1 based query uses the index (so says explain). Can't tell the speed difference in the sqlfiddle, but might help in the full size query.
Upvotes: 1