Grupy dyskusyjne Google nie obsługują już nowych postów ani subskrypcji z Usenetu. Treści historyczne nadal będą dostępne.

Query causes SQLServer to behave badly

0 wyświetleń
Przejdź do pierwszej nieodczytanej wiadomości

Bill Barksfield

nieprzeczytany,
30 sty 2003, 10:57:5130.01.2003
do
I am firing the following prepared statement at a table of
2.7 million rows and 57 columns with multiple indexes

select *
from table
where
columnA = ? -- uniqueidentifier
and columnB is not null -- uniqueidentifier
and columnC = 'O'
and columnD is null
order by columnB -- uniqueidentifier

columnA, columnB, columnC and columnD are indexed

For a the particular value of columnA the query returns
approx 11,000 rows

You may think it odd to order by a uniqueidentifier but
all I need is to group the sets of rows together
for my processing

When fired through QueryAnalyzer (with the ? filled in
with the actual value) the response is fine taking just
a few seconds to begin returning values

When I run my program using Openlink multi-tier drivers
the response is also fine (but we're trying to get away
from using these which is why I am using the MS drivers)

When I run my program using MS drivers it takes 1hr20min
to get the results back

Observing sqlserver.exe using TaskManager on the server I
see that it rapidly proceeds to use up all available
memory (about 1.3Gbytes) on my server and then sit there
(possibly paging?) consuming very little cpu

I have found a temporary workaround which is to add an
inconsequential column to the order by clause :

order by columnB, columnE

which restores the performance to normal

Many other queries on this table and many others on other
tables, large and small, in the database using the MS
drivers work fine

Has anyone seen this kind of behaviour before?
Can anybody work out what SQLServer is doing and how I can
prevent it happening in future?

Nowe wiadomości: 0