Subject Re: [firebird-support] Select count(*) using pk
Author Adomas Urbanavicius
>>There's nothing to speed up count (*) it's rather a no-no. ;-)

Well, in FB there is nothing, but theoretically, if we think in abtract way : automatic counter for each table
record_count++ on insertion, and record_count-- on deletion, and retrieval that counter from select count(*) ...
would be much faster. (especally with 14 mil. records :))

Adomas



>Dirk,
>
>dirknaudts schrieb:
>
>
>>Hi All,
>>
>>It seems that doing a select count(*) from mytable, where mytable has
>>a pk, FB 1.5.1 doesn't use that PK to speed up the count.
>>
>>
>
>select count (*) isn't faster or slower than select count (primary_key)
>since in both cases the whole table has to be scanned and every record
>has to be looked at if it's valid within the transaction (if so count is
>increased) or not.
>
>There's nothing to speed up count (*) it's rather a no-no. ;-)
>
>Luc.
>
>