Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

slowdown of query using <>0 in sum field

Status
Not open for further replies.

hedgracer

Programmer
Joined
Mar 21, 2001
Messages
186
Location
US
I have a query that has a <>0 in a summed number field. The query runs extremely slow (30+ seconds) when this parameter is in this field. If I eliminate this parameter the query runs in milliseconds. This is a query on a linked odbc sql server 2005 table. Any thoughts on the theory of why this happens? Thanks.

Dave
 
does it matter if it sums a zero? that shouldn't change the total....

1+2+3 = 6
1+2+0+3 = 6



Leslie

In an open world there's no need for windows and gates
 
This is actually a theory question. The query in question yields 294 rows with <>0 and 296 rows without <>0 so the omission is no big deal. I just wondered why the slowdown happened in the first place.

Dave
 
any time you use a not equals function it will slow down the query....

Leslie

In an open world there's no need for windows and gates
 
Are you running some kind of timer or are you just looking visually when the data starts to return to the screen?

If you are looking visually, then an non-aggregate query will start returning records when a threshold is reached, say 100 records. An aggregate query has to aggregate all the records before any can be returned to the client.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top