I have a table named Accounts as shown below in phoenix
AccountId | Name | Branch | Transactiondate |
123 | Rajesh | abc | 20170413 |
124 | Sachin | def | 20170112 |
125 | Rajesh | mno | 20170314 |
126 | Bahubali | mno | 20170314
|
127 | Sachin | pqr | 20170202 |
AccountId is the primary key
An index is created as
- CREATE INDEX accountidx ON Accounts(Name,Transactiondate) INCLUDE (Branch)
The following query hits the index and index is used
select AccountId,Name,Transactiondate from Accounts where Name = 'Rajesh' AND Branch = 'abc'
whereas the below query doesn't make use of the index
select AccountId,Name,Transactiondate from Accounts where Name = 'Rajesh' OR Branch = 'abc'
Why is it so, AND works whereas OR doesn't work.
Any thoughts would be great