Search This Blog

Friday, September 28, 2007

Force Optimiser to use Index

To force optimiser to use a specific index we can specify the index name in the select statement
using WITH clause like

SELECT au_id,au_lname from authors WITH Index(0)

To use a particular index
With Index(Index name)

To use table scan
With Index(0)

To use Clustered Index
With Index(1)

However its not a good practice to force a index to be used,as optimizer would have tried various ways of retriving the data like using table scan , clustered,non-clustered and then only choosen the best method to retreive the same

No comments: