I have a table with the following columns.
Customer Id, SSN and rest of the columns.
I have two queries, one with WHERE criteria as CustomerId and other with
WHERE criteria as SSN.
I have created two Index on the above table. One index uses CustomerId as
the indexed column and other index uses SSN as the Index column.
So when I run the queries how to find out that SQL Server used the
appropriate index. Is it possible to specify the index while running the
query through the application?
Thanks,
AkshayRun your query by enabling Execution plan in Query Analyzer
Thanks,
RK
"Akshay Sen" wrote:
> I have a table with the following columns.
> Customer Id, SSN and rest of the columns.
> I have two queries, one with WHERE criteria as CustomerId and other with
> WHERE criteria as SSN.
> I have created two Index on the above table. One index uses CustomerId as
> the indexed column and other index uses SSN as the Index column.
> So when I run the queries how to find out that SQL Server used the
> appropriate index. Is it possible to specify the index while running the
> query through the application?
> Thanks,
> Akshay
>
>
>
>|||and as for the second one: yes, you can specify which index to be used, via
a hint:
select ... from table with(index(index_name))
but you should better leave to sql server to determine the execution plan,
and the indexes used. sql server's reasoning is based on number of factors,
like column and index statistics, which change over time and which your
application doesn't know about. even worse, the execution plan that was
optimal once, might become less than optimal as tha data in tables change.
dean
"Ram Kumar Koditala" <RamKumarKoditala@.discussions.microsoft.com> wrote in
message news:CDC6F3B0-4377-4801-BDD2-A696BF76B791@.microsoft.com...
> Run your query by enabling Execution plan in Query Analyzer
> Thanks,
> RK
> "Akshay Sen" wrote:
>
as
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment