How can I compare the performance of an Index on a table using the Query Analyzer?
I would like to run the same query through the Estimated Execution Plan twice, once using the index and once without, and have a good comparison of the table scans/index scans that are generated.
I have tried CREATE INDEX…, SELECT…, DROP INDEX…, SELECT. I expect the first query to use the index and the second to have no index, but both execution plans will use the index.
The technique that ended up working for me was to use the WITH keyword in the FROM clause.
When the index is created:
The first query will (probably) use the index, the second will not.
You could also use multiple indexes like: