Re: [sqlite] Check for empty table

2006-12-13 Thread Dennis Cote
RB Smissaert 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. But I am not sure if a table always has the hidden field ROWID. RBS

Re: [sqlite] Check for empty table

2006-12-13 Thread Scott Hess
On 12/13/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: "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)

Re: [sqlite] Check for empty table

2006-12-13 Thread Martin Jenkins
Scott Hess wrote: What's wrong with "SELECT COUNT(*) FROM table;"? It scans the whole table. This is OK if the table is small (nearly) empty, but if it has a couple of million rowZzzz Martin - To unsubscribe,

Re: [sqlite] Check for empty table

2006-12-13 Thread Nicolas Williams
On Wed, Dec 13, 2006 at 06:07:56PM +, RB Smissaert wrote: > Nothing wrong, but is it the fastest? count(*) doesn't read every record in the table. - To unsubscribe, send email to [EMAIL PROTECTED]

Re: [sqlite] Check for empty table

2006-12-13 Thread Derrell . Lipman
"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

RE: [sqlite] Check for empty table

2006-12-13 Thread RB Smissaert
Nothing wrong, but is it the fastest? RBS -Original Message- From: Scott Hess [mailto:[EMAIL PROTECTED] Sent: 13 December 2006 17:25 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Check for empty table On 12/13/06, RB Smissaert <[EMAIL PROTECTED]> wrote: > Trying to find th

Re: [sqlite] Check for empty table

2006-12-13 Thread Scott Hess
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

Re: [sqlite] Check for empty table

2006-12-13 Thread Rich Shepard
On Wed, 13 Dec 2006, RB Smissaert 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. RBS About a month ago, I sought a better solution than