Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
arupkumarm
Starting Member
5 Posts |
Posted - 2007-01-15 : 06:29:17
|
| HiI am having a query SELECT Dur1.rootId FROM DurableEventTab Dur1 WHERE (Dur1.dev_ReferenceClusterRoot = 'iyrwd.52' )AND Dur1.dev_Action = 'Order:Ordered') AND (Dur1.dev_Active = 1) AND (Dur1.dev_PurgeState = 0) AND (Dur1.dev_PartitionNumber = 0)This table has a primary key : aribapk11 and the indexes on the dev_ReferenceClusterRoot,dev_Action,dev_purgestate . Now when I fire this query the query execution plan is actaull doing a Clustered Index scan on the PK :aribaPK11 . What I was expecting was an index seek on the key defined on dev_referenceClusterRoot. Please not the index seek is the behaviour in sql server 2000.Any idea what is going wrong ?Clustered Index Scan(OBJECT:([typhoon1902].[dbo].[DurableEventTab].[AribaPK7] AS [Dur1]), WHERE:([typhoon1902].[dbo].[DurableEventTab].[dev_Active] as [Dur1].[dev_Active]=(1.) AND [typhoon1902].[dbo].[DurableEventTab].[dev_PurgeState] as [Dur1].[dev_PurgeState]=(0) AND [typhoon1902].[dbo].[DurableEventTab].[dev_PartitionNumber] as [Dur1].[dev_PartitionNumber]=(0) AND [typhoon1902].[dbo].[DurableEventTab].[dev_ReferenceClusterRoot] as [Dur1].[dev_ReferenceClusterRoot]='iyrwd.52' AND [typhoon1902].[dbo].[DurableEventTab].[dev_Action] as [Dur1].[dev_Action]=N'Order:Ordered')) 0 0 Clustered Index Scan Clustered Index Scan OBJECT:([typhoon1902].[dbo].[DurableEventTab].[AribaPK7] AS [Dur1]), WHERE:([typhoon1902].[dbo].[DurableEventTab].[dev_Active] as [Dur1].[dev_Active]=(1.) AND [typhoon1902].[dbo].[DurableEventTab].[dev_PurgeState] as [Dur1].[dev_PurgeState]=(0) AND [typhoon1902].[dbo].[DurableEventTab].[dev_PartitionNumber] as [Dur1].[dev_PartitionNumber]=(0) AND [typhoon1902].[dbo].[DurableEventTab].[dev_ReferenceClusterRoot] as [Dur1].[dev_ReferenceClusterRoot]='iyrwd.52' AND [typhoon1902].[dbo].[DurableEventTab].[dev_Action] as [Dur1].[dev_Action]=N'Order:Ordered') [Dur1].[rootId] 1 0.00386574 0.0002263 71 0.00409204 [Dur1].[rootId] PLAN_ROW 0 1 |
|
|
arupkumarm
Starting Member
5 Posts |
Posted - 2007-01-15 : 08:45:21
|
| create a table emp ( id varchar(50 PK) name varchar (50) indexed status inr indexed)Now populate some data and the fire the query select * from emp where name ='XX' and status=0. You will see the SQL 2K5 performs an index scan on the column "ID" . I am not so sure , but looks kind of strange to me . |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-15 : 08:53:39
|
| I believe it's because you are not including PK column (ID) in the search criteria.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
arupkumarm
Starting Member
5 Posts |
Posted - 2007-01-15 : 09:39:26
|
| Yes , Since I am not using the primary key(ID) in the join condition , I was expection that the query plan to do a index seek on the varchar column 'NAME'. Some how because of this I am getting a higher CPU cost. select * from arup_emp where NAME='Arup' and status=0 |
 |
|
|
|
|
|