I have a query that is taking a bit to run it looks like this.
from Table A a
inner join Table B b
on a.columnB = b.ColumnB
Where a.columnA = @VariableA
Now it has a clustered index on Table A like this
Clustered Index on ColumnA
It also has a nonclustered index on Table A like this
NonClustered Index on (ColumnA,ColumnB) include (ColumnC,ColumnD)
Should I add ColumnsE-G into the index as well?
Best How To :
Verify the data type of compared columns and parameters are the same when you see an index scan instead of the expected seek in the execution plan.
When data types differ, SQL Server must first convert the operand with the lower precedence to the higher precedence data type (e.g.
nvarchar). When it is the column value that must be converted, the conversion prevents an index on a column from being used efficiently because the column value of each row must be converted before the comparison can be done. This is known as a non-sargable expression and prevents the more efficient index seek.