"Scott Hess" <[EMAIL PROTECTED]> writes: > On 12/13/06, RB Smissaert <[EMAIL PROTECTED]> wrote: >> Trying to find the fastest way to determine if a table has no rows. >> >> I think this will do: >> SELECT (SELECT ROWID FROM table limit 1) IS NOT NULL; >> If a table has rows then the result should be 1. > > What's wrong with "SELECT COUNT(*) FROM table;"?
COUNT(*) is generally slow. It actually iterates over every row, so with large tables, it's very slow. By using a query with a "LIMIT 1", you ensure that as soon as a single matching row is found, no additional rows are searched for. Derrell ----------------------------------------------------------------------------- To unsubscribe, send email to [EMAIL PROTECTED] -----------------------------------------------------------------------------