MySQL Forums
Forum List  »  Newbie

Re: Very long query doubt... (Monster query...)
Posted by: Rick James
Date: March 30, 2009 08:04PM

If more than 30% of the rows match
fecha >= '2008-09-01' and fecha <= '2008-09-30'
it won't bother with the index.

* Using the index means reading through the index, and for each date that matches, reach over into the data (random fetch) to find the rest of the row info.
* Not using any index means simply reading all the data; no random fetches.

One minor improvement (in shrinking the table)
cod_serie int(5)
Do you mean that cod_serie is a SMALLINT? If so, say so. SMALLINT takes 2 bytes; INT takes 4. (The "(5)" has nothing to do with the data size.)

I don't think you can get that query to go any faster. I don't think any other indexes will help. You could turn some of the ORs into UNIONs, but that would be awfully messy, for possibly little gain.

Oh, are you CPU bound or I/O bound? How much RAM do you have and what is the value of key_buffer_size?

Options: ReplyQuote

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.