I have a question about using Order By in my SOQL. My query looks like this
Select Id,FirstName,LastName from Contact Order By FirstName Limit 100.
Here is what I'm trying to achieve I have a search component which on load shows me a drop down with 100 Contacts and when I type ahead it shows me a list of Contacts that matches the criteria i.e Name.This seems to be working fine however when I was checking the Query performance using Query Plan in Developer Console I noticed the Cost is showing a major difference with and without using Order By Clause.For example I noticed the following numbers.
Using Order By : Cost Rate = 0.5567
Without Order by : Cost Rate = 0.18
Any idea on how to overcome this and by the way I applied filters using where clause I still see this considerable difference.
I have close to 3 Million Contacts in my org.