Monday, March 19, 2012

Force Index Use

Hi

I have a reporting procedure that fetches a great deal of data
and is currently taking too long to retrieve the results (40 sec).
Looking at the execution plan, I see SQL is not using some of the indexes I added especially for the queries benefit (ie.time column), usually it uses the clustered composite PK.
Does anyone know how I can force SQL to use a particular index on
a query?

advice appreciated...

Thanks
Desmondno worries.., got it...(BOL)
Desmond|||after table name or table alias in SELECT clause and/or in JOIN clause put (INDEX=index_name)|||thanks...still needed the syntax!
des|||Originally posted by DesmondX
thanks...still needed the syntax!
des

Check this:

drop table test13
go
create table test13(id int identity primary key, code varchar(10))
go
create index i_test13 on test13 (code)
go
select * from test13 with(index(i_test13))
select * from test13 (index=i_test13)

No comments:

Post a Comment