Subject Re: Efficient Record Count
Author mmenaz
Your topic is "efficient", so I'm thinking to a quick and dirty solution.
I think that you have to check the table size in a fast way, but you can spend much more time if you have to "slim" it.
If your main table uses a generator, you can perform the following:
the very first time, you count the record (... count(*)), even if it tokes a long time.
Then you store in a table the number of records plus the actual generator value.
Every time you want, you can calculate the actual generator number and compare it to the stored values (addedrec=newgen-(oldgen-oldcount)).
Of course, this does not take care of the rows deleted by users, but it should be a minor issue.
If the difference is beyond the value you decide, then:
delete old records
recount table record number
update the table with the new values (recordcount and generator).
you could also perform gback and restore.. ;)
This way is very fast for the check :)
Regards
Marco Menardi

--- In IBObjects@y..., "dkLists" <dklists@y...> wrote:
> All -
>
> I have a large table with approximately 1 million rows that will be continually growing over time. It is useful to be able to review the recordcount whenever I run my app and add/delete data. I've been trying to come up with an efficient way to maintain a 'running' record count without loading the entire dataset to the client, i.e. autofetchall.
>
> Would it be much faster to do this in a stored procedure? If so, would it be as simple as doing a SELECT COUNT(*) FROM TABLE? If not, is there a particular IBObjects component that should be used?
>
> All advice welcome.
>
> Thanks in advance.
> ___________________________________
> GreatLand Technology
>
> inquiries@g...
> ___________________________________
>
>
> [Non-text portions of this message have been removed]