MySQL Forums
Forum List  »  Performance

Re: mysql query with modulus in where clause
Posted by: Rick James
Date: January 12, 2013 11:13AM

> WHERE (2567 -lastModifiedCalendarId) % 7 =0

There is no advantage in trying to optimize "% 7" (assuming the values are somewhat evenly distributed. The optimizer is likely to decide that a table scan is better than bouncing between an index and the data.

> and 2567 - lastUsedCalendarId < 7

On the other hand, _this_ might be optimizable:

AND lastUsedCalendarId > 2567 - 7

would let the optimizer consider using

> index idx_lastUsedCalendarId(lastUsedCalendarId)

The optimizer will not (or at least very rarely) use more than one INDEX in a single SELECT. So, based on what I see so far, this is useless:

> index idx_lastModifiedCalendarId(lastModifiedCalendarId),

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: mysql query with modulus in where clause
1997
January 12, 2013 11:13AM


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.