I know that both Wild Cards and Functions must be avoided in the WHERE clauses if possible. My question is: which one is yet better in terms of performance, assuming that we have to choose between one of them? More specifically, I have the following two queries and I want to know which type of query is preferred in general:
select FirstName from person.person where FirstName like 'S%'
select FirstName from person.person where LEFT(FirstName,1) = 'S'
PS. I have checked the execution time of both queries and there was no noticeable difference in this specific case. Here are the execution plans:
This is the code for the index IX_Person_LastName_FirstName_MiddleName is defined:
USE [AdventureWorks2012]
GO
/****** Object: Index [IX_Person_LastName_FirstName_MiddleName] Script Date: 11/30/2016 12:53:05 PM ******/
CREATE NONCLUSTERED INDEX [IX_Person_LastName_FirstName_MiddleName] ON [Person].[Person]
(
[LastName] ASC,
[FirstName] ASC,
[MiddleName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO;
Here is a few links I found about this issue, though they do not completely answer my question: