I have a index on a column and it is correctly used when the query is
select * from Table where x = 'somestring'
However it seems to be not used when the query is something like
select * from Table where x != 'someotherstring'
Is this normal or am I missing something else in the query? The actual query is of course much larger and so it could be caused by some other factor. Any other ideas why an index would not be used in a query?
This is normal. Index will only be used if you have a ‘=’ condition. Searching index for != condition is not effective.
Similarly, this may use the index (in Oracle)
but this wouldn’t
Also,
select * from Table where x between 1 and 10will use the indexbut not
select * from Table where x not between 1 and 10