I have the following query that is taking a long time to execute.
SELECT
Table1.A, Table1.B, Table2.C
FROM
Table1
INNER JOIN Table2
ON Table1.UniqueCol = Table2.UniqueCol
WHERE
Table1.UniqueCol = @storedProcParam
Both tables have a unique nonclustered index on UniqueCol which is a varchar(64) but neither has it as its primary key. One of the tables has a few million records and the other has a few thousand. Is it the fact that the column is a varchar(64) that is holding back performance, or is there something else I'm missing?
UniqueColfield, how is the@storedProcParamdefined? Is it defined as a parameter to a stored procedure or a local variable in the stored procedure. I've seen better performance on query cache of the execution plan when using a local variable vs. a passed in variable. Not much else to go by though...