In a query like this
SELECT * FROM myTable WHERE date = LEAST(maxDate, '2013-12-31')
I am looking for an index that will be used during execution. date and maxDate are Date types.
Any suggestions?
Use of function(UDF or built-in) in WHERE clause don't take advantage of existing indexes but you can modify your query like below which will be using the already existing indexes on date or maxdate (if there is any) column like
SELECT * FROM myTable
WHERE date = case when maxDate > '2013-12-31' then maxDate else '2013-12-31' end
HASH index on maxDate or date is not used that way ...