Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread TOP xxx of little benefit?
Wed, May 2 2007 6:29 PMPermanent Link

Kerry Neighbour
I have read your thread on the discussion of this, and a recent post made
to the effect that TOP would probably not speed up a slow query.

In my experience, this is certainly not the case. I have found that TOP 1000
speeds up my queries no end. For example, one big query on 100,000 records
goes from 76 seconds to 0.687 seconds! A vast improvement. For this reason,
on all of my user screens I have a spinbox so the user can set the TOP amount
(normally 1000).

I agree that if the result set does not contain 1000 records, then the speed
will be the same.

It seems to me, and I could be wrong, that the query is run UNTIL the 1,000
records are found, then it stops. It cerainly seems that way as a user running
the query.

While I am happy with the way TOP works, it would be interesting to see why
it maybe should not work the way it seems to.

Thu, May 3 2007 3:58 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Kerry,

<< I have read your thread on the discussion of this, and a recent post made
to the effect that TOP would probably not speed up a slow query. >>

No, what I said is that it doesn't necessarily speed up a query in a lot of
cases.  The only time that it does is if there is an index on the column in
the ORDER BY that you're using, or if you're not using an ORDER BY at all.
If DBISAM has to use a temporary index to perform the ordering, then it has
to run the entire query before it can provide the TOP processing, negating
any performance benefits.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image