PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > Query timeout, but sometimes the same query is fast. Table with 1.2million records.
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Query timeout, but sometimes the same query is fast. Table with 1.2million records.

Réponse
 
LinkBack Outils de la discussion
Vieux 03/09/2008, 20h03   #1
ivo@ritense.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Query timeout, but sometimes the same query is fast. Table with 1.2million records.

This is the first time I'm confronted with this type of problem,
probably since I was not using larger databases before, but now I'm
stuck and hoping someone can point me in the right direction.

I have a table in a database on my SQL Server 2005 Standard edition
server, running on a W2k3 box with 4Gb memory, 1 quad core processor.
The table has 1.2 million records. A query like "select count(id) from
table" returns almost instantly. When I change the query to this
"select count(id) from table where columnA = 'test'" the query times
out. Execution error timing out. But it gets worse. When I wait for
ten minutes or something and retry, this second query also returns
almost instantly. From this point I start running these type of
queries a lot, this works well for five or ten minutes, then suddenly
stops and returns timeouts again for the exact same query. At this
point the processor load is 1 or 2 procent (basically flatlining) and
memory usage is somewhere around 1.2 Gb of which SQL uses 800Mb. No
other big things on the server. The queries timeout both using
Management Studio and a JDBC connection from my application server.

When this behavior was constantly the same, I would not be surprised.
Maybe I need an index on that columnA. But it is sometimes fast, then
ten minutes later it is a timeout. Can't explain it. Is there anybody
with a quick tip?
  Réponse avec citation
Vieux 03/09/2008, 21h17   #2
Tibor Karaszi
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Query timeout, but sometimes the same query is fast. Table with 1.2 million records.

It is either blocking (sp_who, sp_who2, Current Activity etc) or that you get different execution
plans for the two cases.

--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://sqlblog.com/blogs/tibor_karaszi


<ivo@ritense.com> wrote in message
news:28544efd-5e74-4bea-9c2d-5d87ffc27fea@x35g2000hsb.googlegroups.com...
> This is the first time I'm confronted with this type of problem,
> probably since I was not using larger databases before, but now I'm
> stuck and hoping someone can point me in the right direction.
>
> I have a table in a database on my SQL Server 2005 Standard edition
> server, running on a W2k3 box with 4Gb memory, 1 quad core processor.
> The table has 1.2 million records. A query like "select count(id) from
> table" returns almost instantly. When I change the query to this
> "select count(id) from table where columnA = 'test'" the query times
> out. Execution error timing out. But it gets worse. When I wait for
> ten minutes or something and retry, this second query also returns
> almost instantly. From this point I start running these type of
> queries a lot, this works well for five or ten minutes, then suddenly
> stops and returns timeouts again for the exact same query. At this
> point the processor load is 1 or 2 procent (basically flatlining) and
> memory usage is somewhere around 1.2 Gb of which SQL uses 800Mb. No
> other big things on the server. The queries timeout both using
> Management Studio and a JDBC connection from my application server.
>
> When this behavior was constantly the same, I would not be surprised.
> Maybe I need an index on that columnA. But it is sometimes fast, then
> ten minutes later it is a timeout. Can't explain it. Is there anybody
> with a quick tip?


  Réponse avec citation
Vieux 04/09/2008, 00h38   #3
Linchi Shea
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut RE: Query timeout, but sometimes the same query is fast. Table with 1.

One more item to Tibor's list. It's also possible that the timeout coincided
with a large autogrow.

Linchi

"ivo@ritense.com" wrote:

> This is the first time I'm confronted with this type of problem,
> probably since I was not using larger databases before, but now I'm
> stuck and hoping someone can point me in the right direction.
>
> I have a table in a database on my SQL Server 2005 Standard edition
> server, running on a W2k3 box with 4Gb memory, 1 quad core processor.
> The table has 1.2 million records. A query like "select count(id) from
> table" returns almost instantly. When I change the query to this
> "select count(id) from table where columnA = 'test'" the query times
> out. Execution error timing out. But it gets worse. When I wait for
> ten minutes or something and retry, this second query also returns
> almost instantly. From this point I start running these type of
> queries a lot, this works well for five or ten minutes, then suddenly
> stops and returns timeouts again for the exact same query. At this
> point the processor load is 1 or 2 procent (basically flatlining) and
> memory usage is somewhere around 1.2 Gb of which SQL uses 800Mb. No
> other big things on the server. The queries timeout both using
> Management Studio and a JDBC connection from my application server.
>
> When this behavior was constantly the same, I would not be surprised.
> Maybe I need an index on that columnA. But it is sometimes fast, then
> ten minutes later it is a timeout. Can't explain it. Is there anybody
> with a quick tip?
>

  Réponse avec citation
Vieux 04/09/2008, 14h51   #4
ivo@ritense.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Query timeout, but sometimes the same query is fast. Table with1.

Thanks a lot both for the tips. I can now better reproduce the error
and it is a memory issue.

When I run the query for the first time, I see memory consumption go
up with 600Mb immediately. After that it runs smoothly, but memory
consumption is going up little by little. Then when it hits total mem
usage of approximately 1.65 Gb, it stops. Other queries still run, but
this one is dead. When I restart SQL Server, it all starts over again.

I guess that when I run a couple of these big queries together, the
problem starts faster.

Will investigate further, but at least I know what to look for.

Again, thanks for your .
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h39.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10138 seconds with 12 queries