Subject Re: [ib-support] is table empty?
Author Martijn Tonies
Hi Fred,


> I am converting a database from Informix to Firebird. So far, I have
found
> Firebird to be quite up to the task and am very impressed with its
maturity,
> performance, and reliability. I do have a question: Informix keeps row
> count information in its table control structures so "select count(*) from
> table" is instantaneous even if the table contains a billion rows. It
> appears that Firebird actually counts the rows. In my app this query is
> often used to determined if a table is empty, so I suppose I could write a
> stored procedure that opens a cursor, does a fetch, and returns a yes/no
for
> table "emptiness". Is there a more elegant way to determine if a table is
> empty in Firebird?

This was recently discussed in this newsgroup. Did you know you
can also read this group via a new-reader interface? You might be
able to find the thread without problems. Alternatively, log-in to
Yahoo and search the newsgroup archives.

In short - you can use:

SELECT min(pkcolumn) FROM table

If this returns a value, there's at least a single row.


With regards,

Martijn Tonies
Database Workbench - the developer tool for InterBase & Firebird
Upscene Productions
http://www.upscene.com

See you at the First European Firebird Conference in May in Fulda, Germany
http://www.firebird-conference.com