MySQL Forums
Forum List  »  Performance

Re: Simple query seems to be ignoring date index
Posted by: Rick James
Date: October 30, 2013 07:47PM

Notice how one EXPLAIN says "Using index"? That means that the entire query could be performed by reading from the index; the data was not needed. The other one did not say that, meaning that it needed to jump back and forth between the index(mdate) and the data.

If it is bouncing back and forth 2488 times, and if the data is scattered around on disk, and if the disk blocks do not happen to be cached in ram, then I would estimate that it would take 2488/100 seconds to run the query. That's 25 seconds; you got
2488 rows in set (12.40 sec)

There are ways to improve the speed of this one query, but they are likely to have impact on other queries. So, let's see all the queries, including the INSERTs/DELETEs/UPDATEs/SELECTs. With that, we can craft a modified schema, and maybe change the queries some, in order to give you better performance overall.

The quick, but dumb, solution is to add
INDEX(date, sym, vol)

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Simple query seems to be ignoring date index
1068
October 30, 2013 07:47PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.