I wonder if there is any wise way to rewrite the following query so that the indexes on columns get used by optimizer?
Have you tries a table valued function?
CREATE FUNCTION select_func1 ( @Key1 int=0, @Key2 int=0 ) RETURNS TABLE AS RETURN ( Select key3 From Or_Table Where (@key1 =0 OR Key1 =@Key1) AND (@key2 =0 OR Key2 =@Key2) ) select * from select_func1(1,2)