How does a database know when to use an
index?
When a query like “SELECT * FROM Employee WHERE Employee_Name = ‘Jesus’ ”
is run, the database will check to see if there is an index on the column(s) being
queried. Assuming the Employee_Name column does have an index created on it, the
database will have to decide whether it actually makes sense to use the index to find
the values being searched – because there are some scenarios where it is actually less
efficient to use the database index, and more efficient just to scan the entire table.
Read this article to understand more about those scenarios: Selectivity in SQL