Quote:
Originally Posted by santana.beto
A friend of my told me that if I create an index to a column, the index is called only if the select matches only one row. In other words if I select using = it works but if I use between not.
|
As a general rule he's wrong, or at least too simplistic. The way indexes are used is highly dependent on your DBMS, the nature of the query, the data and the type of index. Perhaps your friend is thinking specifically of hash indexes which only work for comparisons based on equality and not on range queries.
The number of rows returned by a query can also be a factor in whether an index gets used or not. If the query returns a large proportion of the rows from a table then the query optimiser may find it more efficient not to use an index.