Question about the RecordCount property 
Author Message
 Question about the RecordCount property

Hi,

i have a question about the RecordCount property of the TIBQuery component. I'd like to find out the number of records the query
returns, so i thought to use the RecordCount property. I have alse set the CachedUpdates to false. Do i always get the correct
number of records in this way or is it necessary that i traverse all of them? If this is not the solution, should i use another
query to execute a "select count(*)" for the first query or is there any other, more simple solution?

Thanx



Sat, 24 Dec 2005 19:51:27 GMT  
 Question about the RecordCount property
It's never a good idea to use RecordCount on a SQL-server.
You can use it, but you must fetch all records before you can use
RecordCount.
You better run that second query.

Alfred.



Quote:
> Hi,

> i have a question about the RecordCount property of the TIBQuery

component. I'd like to find out the number of records the query
Quote:
> returns, so i thought to use the RecordCount property. I have alse set the

CachedUpdates to false. Do i always get the correct
Quote:
> number of records in this way or is it necessary that i traverse all of

them? If this is not the solution, should i use another
Quote:
> query to execute a "select count(*)" for the first query or is there any

other, more simple solution?
Quote:

> Thanx



Sun, 25 Dec 2005 02:31:33 GMT  
 Question about the RecordCount property



Quote:
> It's never a good idea to use RecordCount on a SQL-server.
> You can use it, but you must fetch all records before you can use
> RecordCount.

Quite correct. The trouble is of course that you have to set
up the "count" query with exactly the same conditions as
the real one. Under these conditions, and maybe using joins
or even sub selects, will the "count" query actually be faster?
A simple Query.Last seems to me the easiest way to get
right recordcount value, although not necessarily the most
efficient. Has anybody done done tests on this?

PR

Quote:
> You better run that second query.

> Alfred.



> > Hi,

> > i have a question about the RecordCount property of the TIBQuery
> component. I'd like to find out the number of records the query
> > returns, so i thought to use the RecordCount property. I have alse set
the
> CachedUpdates to false. Do i always get the correct
> > number of records in this way or is it necessary that i traverse all of
> them? If this is not the solution, should i use another
> > query to execute a "select count(*)" for the first query or is there any
> other, more simple solution?

> > Thanx



Sun, 25 Dec 2005 11:18:00 GMT  
 Question about the RecordCount property

Quote:



> > It's never a good idea to use RecordCount on a SQL-server.
> > You can use it, but you must fetch all records before you can use
> > RecordCount.

> Quite correct. The trouble is of course that you have to set
> up the "count" query with exactly the same conditions as
> the real one. Under these conditions, and maybe using joins
> or even sub selects, will the "count" query actually be faster?
> A simple Query.Last seems to me the easiest way to get
> right recordcount value, although not necessarily the most
> efficient. Has anybody done done tests on this?

Do you really need the count?  Actually, the best "solution" is to not bother
with it.

--
Aage J.



Mon, 26 Dec 2005 14:34:23 GMT  
 Question about the RecordCount property


Quote:



> > > It's never a good idea to use RecordCount on a SQL-server.
> > > You can use it, but you must fetch all records before you can use
> > > RecordCount.

> > Quite correct. The trouble is of course that you have to set
> > up the "count" query with exactly the same conditions as
> > the real one. Under these conditions, and maybe using joins
> > or even sub selects, will the "count" query actually be faster?
> > A simple Query.Last seems to me the easiest way to get
> > right recordcount value, although not necessarily the most
> > efficient. Has anybody done done tests on this?

> Do you really need the count?  Actually, the best "solution" is to not
bother
> with it.

The only time when I need a count is to give an indication to the
user that the computer has not locked up and give an
approximation of how far processing has progressed.
In technical terms there is rarely a use for it, in human terms there is.
It is the difference between twiddling my thumb while getting
frustrated or having a cup of coffe, or doing some useful work
in the meantime.

PR



Tue, 27 Dec 2005 12:09:06 GMT  
 Question about the RecordCount property

Quote:






> > > > It's never a good idea to use RecordCount on a SQL-server.
> > > > You can use it, but you must fetch all records before you can use
> > > > RecordCount.

> > > Quite correct. The trouble is of course that you have to set
> > > up the "count" query with exactly the same conditions as
> > > the real one. Under these conditions, and maybe using joins
> > > or even sub selects, will the "count" query actually be faster?
> > > A simple Query.Last seems to me the easiest way to get
> > > right recordcount value, although not necessarily the most
> > > efficient. Has anybody done done tests on this?

> > Do you really need the count?  Actually, the best "solution" is to not
> bother
> > with it.

> The only time when I need a count is to give an indication to the
> user that the computer has not locked up and give an
> approximation of how far processing has progressed.
> In technical terms there is rarely a use for it, in human terms there is.
> It is the difference between twiddling my thumb while getting
> frustrated or having a cup of coffe, or doing some useful work
> in the meantime.

Right.  What I usually do is to show a running counter.  I cannot give an
estimate of 'arrival time', but it does show that something, somewhere is
doing some work.

--
Aage J.



Tue, 27 Dec 2005 15:00:38 GMT  
 Question about the RecordCount property
"RecordCount" always returns zero on an SQL dataset.  If you want to
know the record count, you must issue a "SELECT COUNT(*)" query.

Also...  these queries are comparatively expensive for a server to
perform, because they force the server to actually do all of the work
for all of the query.  (Query optimizers like to defer as much work as
possible, in case you don't actually ask for it.)  If you are simply
doing this to present a nice "informative" message to the user, think
twice.

Quote:



> > It's never a good idea to use RecordCount on a SQL-server.
> > You can use it, but you must fetch all records before you can use
> > RecordCount.

> Quite correct. The trouble is of course that you have to set
> up the "count" query with exactly the same conditions as
> the real one. Under these conditions, and maybe using joins
> or even sub selects, will the "count" query actually be faster?
> A simple Query.Last seems to me the easiest way to get
> right recordcount value, although not necessarily the most
> efficient. Has anybody done done tests on this?



Sun, 01 Jan 2006 10:22:36 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. TQuery RecordCount property

2. dBase DataType Property Question

3. Delphi : Properties Question

4. Newbie: Question about editmask property.

5. Counting Detail records with SQL or Recordcount

6. RecordCount in Paradox 7.0 Queries.

7. Spurious RecordCount for certain parameterized queries

8. RecordCount Problem

9. recordcount

10. DBGrid focus on RecordCount = 0

11. RecNo e RecordCount in ACCESS 97

12. Problem in RecordCount with Delphi4 and Paradox

 

 
Powered by phpBB® Forum Software