MySQL Forums
Forum List  »  Performance

Re: Find free appointments faster
Posted by: Øystein Grøvlen
Date: November 14, 2017 09:31AM

Hi,

It may be that the condition on date reduces the number of candidate rows so much that the additional savings from using the index to restrict on time_start/time_end is smaller than the overhead of more subqueries. So it might not be more to save here.

If you need to add/substract a second, you should do it to the operand that is constant not to the column since the latter prevents the use of index. However, I think you can achieve what you want without adding seconds. If you have to intervals (a,b) and (c,d), could you not say that these overlap only if
c < b <= d OR a < d <= b
I.e., intervals do not overlap when start time of one interval equals end time of the other.

Øystein Grøvlen,
Senior Principal Software Engineer,
MySQL Group, Oracle,
Trondheim, Norway

Options: ReplyQuote


Subject
Views
Written By
Posted
3692
November 08, 2017 12:32AM
723
November 08, 2017 12:48AM
755
November 08, 2017 10:43PM
745
November 08, 2017 11:31PM
671
November 09, 2017 09:27AM
692
November 14, 2017 10:19AM
Re: Find free appointments faster
674
November 14, 2017 09:31AM
759
November 08, 2017 11:22PM


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.