Subject Re: [firebird-php] ibase_num_rows instead of count(*)
Author Lester Caine
Dariusz Zelichowski wrote:

> I have an application in which I always need to know the
> exact number of rows in some (not all) tables. I also found
> count(*) to be on a slow side sometimes, although using
> count(*) with a WHERE clause against indexed fields should
> speed things up.
>
> Regardless, for each table where I need the row count I
> created an extra table with one row and one field in it.
> The field contains the number of records for one table.
> Then I created 2 stored procedures INC_REC_COUNT and
> DEC_REC_COUNT. Those are called via a trigger AFTER INSERT
> or AFTER DELETE, respectively. Kinda a home brewed solution
> but as of now this is the fastest solution I could think
> of.

That is exactly the way it should be done.
Could have a single table of counts. The magic bit is to keep counts of
groups of records as well. MySQL could not even start to touch that yet ;)

--
Lester Caine
-----------------------------
L.S.Caine Electronic Services