SQL Server 2005 charindex performance
I am trying to run an update query that updates one table based on the rows it finds in another table where a specific value exists anywhere in one of the column values ββof a remote table. I am using the following query:
update
c
set
LastStep = @StepNumber,
LastDate = pv.Created
from
@Conversions c
inner join PageViews pv on c.SessionID = pv.SessionID
where
c.GoalName = @GoalName AND
pv.Created > c.LastDate AND
charindex(@MatchValue, pv.PageUrl) > 0;
In a test database with 50,000 rows in the PageViews table, this single query only produces over 1 million reads according to the SQL profiler and takes 1 minute and 14 seconds. Any ideas why?
0
source to share