Subject | Re: [IBO] Order By |
---|---|
Author | Svein Erling Tysvær |
Post date | 2002-03-04T15:37:43Z |
> I have a query which returns instantly, until I add the 'Order By'How many rows does your query return? The ordering is done on the result
> clause and order the result with three fields. The query then takes
> 50 seconds ( The plan stays the same ).
set, but it will have to find the entire result set before it can do the
ordering (all this is done on the server). IBO doesn't necessarily fetch
all records immediately, and this may be the reason for the "instant
return" of your query without any order by.
> A related 2nd question - if I get a result set and also want to countWell, you could do it manually by looping through your entire result set
> how many records in the result - I see the query is fired again when
> I use the recordcount method, replacing the select ... with select
> count(*) How can I just count the records of the result ?
(though I'd expect this to take you at least 50 seconds). I'd guess that
the reason for Jason issuing a count(*) is that it is normally the
fastest (and safest) way to do things (I don't know, just trust there is
a reason for the count(*)).
In general, counting records can be an expensive operation in c/s
applications. Some time ago, there were even a discussion about how
RecordCount should behave and I think it ended up in having another
method RecordCountAccurate for counting all records (in some situations,
RecordCount would only return a count of what was in the buffer or
something).
HTH,
Set