I\'ve searched around stackoverflow but everybody asks to optimize queries they\'ve already done.
I want to know, the basic stuff on what to do, what to avoid when creat
From what I've read, using BETWEEN
instead of two checks on an index, using AND
, improves performance because your database may not fully utilize the benefits of indexes when it sees that it is used on both sides of an AND
, or OR
.
The query optimizer may not be able to intuit that this is a range check and that the index sorting can come in handy. Instead it may do a scan on each condition and then combine the results. On the other hand, this is very clear with a BETWEEN
clause that compares the index column to two values.