|Subject||Re: [firebird-support] If Not SELECT COUNT(*), Then What?|
At 09:14 PM 10/12/2008, you wrote:
>Hi Folks:It's an inefficient (and not very safe) way to perform an existence test.
> I had a bug in a function that is passed a table
>name and a where clause, and returns a count of the
>records that qualify for the where clause, if one is
> The function builds an SQL of
> COUNT(*) FROM
> <Table Name>
> WHERE <--------- If where clause passed in
> <Where Clause>;
> While tracking down the problem I read in Helen's
>book that SELECT COUNT(*) is inefficient.
> Should I re-think the use of COUNT(*) in this function?As long as you *need* it to COUNT things, no, there's no other way to count things. But if the idea is to count all the records so you can know ahead of time how many records there are going to be - as e.g. for a progress bar - then that's inefficient. But there are still a lot of people out there writing apps like that....and complaining about Firebird's performance... ;-)