I have a stored procedure that I am trying to improve performance on.
62% of the time is MapStreets.PK_MapStreets. FeatureId is the primary key for the MapStreets table. I've made this a clustered index. For some reason, it is doing a scan instead of a seek.
I have the same problem with the MapStreetsPoints table. FeatureId and Point Number are the primary key for this table. This step takes 21% of the execution time.
The execution plan looks like.
A = Select 0%
B = Sort 2%
C = Merge Join/Inner Join 11%
D = Merg Join/Inner Join 4%
E = MapStreetsGridFeatures - Index Seek 0%
F = MapStreets.PK_MapStreets - Clustered Index Scan 62%
G = MapStreetsPoints.MapStreetsPoints_FeatureId - Clustered Index Scan 21%
What can I do to make this any faster?
Am I correct in assuming that seeks are faster than scans.
-George
Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
Code:
ALTER PROCEDURE dbo.MapGetStreetsForGrid
@GridNumber Integer
As
SET NOCOUNT ON
Select MapStreetsGridFeatures.FeatureId,
MapStreets.Label,
MapStreetsPoints.Longitude,
MapStreetsPoints.Latitude
From MapStreetsGridFeatures
Inner Join MapStreets On MapStreetsGridFeatures.FeatureId = MapStreets.FeatureId
Inner Join MapStreetsPoints On MapStreetsGridFeatures.FeatureId = MapStreetsPoints.FeatureId
Where MapStreetsGridFeatures.GridNumber = @GridNumber
Order By MapStreetsGridFeatures.GridNumber, MapStreetsGridFeatures.FeatureId, PointNumber
62% of the time is MapStreets.PK_MapStreets. FeatureId is the primary key for the MapStreets table. I've made this a clustered index. For some reason, it is doing a scan instead of a seek.
I have the same problem with the MapStreetsPoints table. FeatureId and Point Number are the primary key for this table. This step takes 21% of the execution time.
The execution plan looks like.
Code:
A <- B <- C <- D <- E
^ ^
| |- F
|
|- G
B = Sort 2%
C = Merge Join/Inner Join 11%
D = Merg Join/Inner Join 4%
E = MapStreetsGridFeatures - Index Seek 0%
F = MapStreets.PK_MapStreets - Clustered Index Scan 62%
G = MapStreetsPoints.MapStreetsPoints_FeatureId - Clustered Index Scan 21%
What can I do to make this any faster?
Am I correct in assuming that seeks are faster than scans.
-George
Strong and bitter words indicate a weak cause. - Fortune cookie wisdom