Saturday, February 25, 2012

Query not using clustered index

I am working with some software vendors with sql query performance on their application that we installed. On one of the tables there are four indexes, one is clustered. When the vendor restores a copy of our database and run a query against that table i
t uses the clustered index and completes in .02 seconds. When I run the same query on the same database it uses a different index than the clustered index and takes 1.7 seconds to run. Is there some way I can get this query to use the clustered index to
run faster? I have a maintinence plan that runs once a week to rebuild the indexes and update statistics using 50%. Any ideas would be appreciated.
When you say the same query on the same database are you talking the same
machine? If so what is different in the way you run the query than when he
does?
Andrew J. Kelly SQL MVP
"russgjones" <russgjones@.discussions.microsoft.com> wrote in message
news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> I am working with some software vendors with sql query performance on
their application that we installed. On one of the tables there are four
indexes, one is clustered. When the vendor restores a copy of our database
and run a query against that table it uses the clustered index and completes
in .02 seconds. When I run the same query on the same database it uses a
different index than the clustered index and takes 1.7 seconds to run. Is
there some way I can get this query to use the clustered index to run
faster? I have a maintinence plan that runs once a week to rebuild the
indexes and update statistics using 50%. Any ideas would be appreciated.
|||When you say the same query on the same database are you talking the same
machine? If so what is different in the way you run the query than when he
does?
Andrew J. Kelly SQL MVP
"russgjones" <russgjones@.discussions.microsoft.com> wrote in message
news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> I am working with some software vendors with sql query performance on
their application that we installed. On one of the tables there are four
indexes, one is clustered. When the vendor restores a copy of our database
and run a query against that table it uses the clustered index and completes
in .02 seconds. When I run the same query on the same database it uses a
different index than the clustered index and takes 1.7 seconds to run. Is
there some way I can get this query to use the clustered index to run
faster? I have a maintinence plan that runs once a week to rebuild the
indexes and update statistics using 50%. Any ideas would be appreciated.
|||It is on a different machine but the same database and indexes. We are both running the query in Query Analyzer.
"Andrew J. Kelly" wrote:

> When you say the same query on the same database are you talking the same
> machine? If so what is different in the way you run the query than when he
> does?
> --
> Andrew J. Kelly SQL MVP
>
> "russgjones" <russgjones@.discussions.microsoft.com> wrote in message
> news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> their application that we installed. On one of the tables there are four
> indexes, one is clustered. When the vendor restores a copy of our database
> and run a query against that table it uses the clustered index and completes
> in .02 seconds. When I run the same query on the same database it uses a
> different index than the clustered index and takes 1.7 seconds to run. Is
> there some way I can get this query to use the clustered index to run
> faster? I have a maintinence plan that runs once a week to rebuild the
> indexes and update statistics using 50%. Any ideas would be appreciated.
>
>
|||It is on a differnet server, but it is the same database and indexes. We are both using query analyzer to run the query.
"Andrew J. Kelly" wrote:

> When you say the same query on the same database are you talking the same
> machine? If so what is different in the way you run the query than when he
> does?
> --
> Andrew J. Kelly SQL MVP
>
> "russgjones" <russgjones@.discussions.microsoft.com> wrote in message
> news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> their application that we installed. On one of the tables there are four
> indexes, one is clustered. When the vendor restores a copy of our database
> and run a query against that table it uses the clustered index and completes
> in .02 seconds. When I run the same query on the same database it uses a
> different index than the clustered index and takes 1.7 seconds to run. Is
> there some way I can get this query to use the clustered index to run
> faster? I have a maintinence plan that runs once a week to rebuild the
> indexes and update statistics using 50%. Any ideas would be appreciated.
>
>
|||It is on a differnet server, but it is the same database and indexes. We are both using query analyzer to run the query.
"Andrew J. Kelly" wrote:

> When you say the same query on the same database are you talking the same
> machine? If so what is different in the way you run the query than when he
> does?
> --
> Andrew J. Kelly SQL MVP
>
> "russgjones" <russgjones@.discussions.microsoft.com> wrote in message
> news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> their application that we installed. On one of the tables there are four
> indexes, one is clustered. When the vendor restores a copy of our database
> and run a query against that table it uses the clustered index and completes
> in .02 seconds. When I run the same query on the same database it uses a
> different index than the clustered index and takes 1.7 seconds to run. Is
> there some way I can get this query to use the clustered index to run
> faster? I have a maintinence plan that runs once a week to rebuild the
> indexes and update statistics using 50%. Any ideas would be appreciated.
>
>
|||Any time you restore a database you should run Update statistics to ensure
they are all set. I would run it the same way on both systems and then see
if the results are the same.
Andrew J. Kelly SQL MVP
"russgjones" <russgjones@.discussions.microsoft.com> wrote in message
news:242F4B00-1365-43C1-807D-882A72DC306E@.microsoft.com...
> It is on a differnet server, but it is the same database and indexes. We
are both using query analyzer to run the query.[vbcol=seagreen]
> "Andrew J. Kelly" wrote:
same[vbcol=seagreen]
he[vbcol=seagreen]
four[vbcol=seagreen]
database[vbcol=seagreen]
completes[vbcol=seagreen]
a[vbcol=seagreen]
Is[vbcol=seagreen]
appreciated.[vbcol=seagreen]
|||It is on a different machine but the same database and indexes. We are both running the query in Query Analyzer.
"Andrew J. Kelly" wrote:

> When you say the same query on the same database are you talking the same
> machine? If so what is different in the way you run the query than when he
> does?
> --
> Andrew J. Kelly SQL MVP
>
> "russgjones" <russgjones@.discussions.microsoft.com> wrote in message
> news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> their application that we installed. On one of the tables there are four
> indexes, one is clustered. When the vendor restores a copy of our database
> and run a query against that table it uses the clustered index and completes
> in .02 seconds. When I run the same query on the same database it uses a
> different index than the clustered index and takes 1.7 seconds to run. Is
> there some way I can get this query to use the clustered index to run
> faster? I have a maintinence plan that runs once a week to rebuild the
> indexes and update statistics using 50%. Any ideas would be appreciated.
>
>
|||It is on a differnet server, but it is the same database and indexes. We are both using query analyzer to run the query.
"Andrew J. Kelly" wrote:

> When you say the same query on the same database are you talking the same
> machine? If so what is different in the way you run the query than when he
> does?
> --
> Andrew J. Kelly SQL MVP
>
> "russgjones" <russgjones@.discussions.microsoft.com> wrote in message
> news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> their application that we installed. On one of the tables there are four
> indexes, one is clustered. When the vendor restores a copy of our database
> and run a query against that table it uses the clustered index and completes
> in .02 seconds. When I run the same query on the same database it uses a
> different index than the clustered index and takes 1.7 seconds to run. Is
> there some way I can get this query to use the clustered index to run
> faster? I have a maintinence plan that runs once a week to rebuild the
> indexes and update statistics using 50%. Any ideas would be appreciated.
>
>
|||It is on a differnet server, but it is the same database and indexes. We are both using query analyzer to run the query.
"Andrew J. Kelly" wrote:

> When you say the same query on the same database are you talking the same
> machine? If so what is different in the way you run the query than when he
> does?
> --
> Andrew J. Kelly SQL MVP
>
> "russgjones" <russgjones@.discussions.microsoft.com> wrote in message
> news:5FF3899A-95F8-4F0E-A91F-F679FA1935F6@.microsoft.com...
> their application that we installed. On one of the tables there are four
> indexes, one is clustered. When the vendor restores a copy of our database
> and run a query against that table it uses the clustered index and completes
> in .02 seconds. When I run the same query on the same database it uses a
> different index than the clustered index and takes 1.7 seconds to run. Is
> there some way I can get this query to use the clustered index to run
> faster? I have a maintinence plan that runs once a week to rebuild the
> indexes and update statistics using 50%. Any ideas would be appreciated.
>
>

No comments:

Post a Comment