April 20, 2010 at 11:30 pm
Hi Expert,
Please provide me the best execution for this query,
Please find the attched sample data,table struc , index and exec plan
Select Top 1 IIDON,DATEDIFF(day, IIDON, '2009-03-10 00:00:00.000')
From t_temp
Where OBD = '0001' AND AID='000110000000030' and
LS = 1 and
IIDON < = '2009-03-10 00:00:00.000' and ((PA > PU) or
(IA > IU) or
(ISNULL(VA,0) > ISNULL(VP,0)))
Order By IID
April 21, 2010 at 12:54 am
Try adding IIDON to the clustered index, like this:
CREATE CLUSTERED INDEX [IX_t_temp] ON [dbo].[t_temp]
(
[obd] ASC,
[AID] ASC,
[LS] ASC,
IIDON
)
This might help depending on the distribution of data in the table.
/SG
April 21, 2010 at 1:18 am
Hi if i add IID order by column there wil be an index seek but i dnt want to do that.
April 21, 2010 at 2:01 am
I dont understand what you mean.
Please be more clear.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply