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
--
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)
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, send
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]
"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
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
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;"?
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 w
8 matches
Mail list logo