Hi,
No the process must count all the rows.  The ROWID value is generated
when a new row is inserted but if you delete rows the last rowid will
not be the same as the count of rows.  If you have an index on the
primary key and count that then it will run as quickly as possible.

Regards
Greg

-----Original Message-----
From: Buzz Weetman [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, 7 January 2004 7:43 AM
To: [EMAIL PROTECTED]
Subject: Re: [sqlite] need faster count(*)


In my particular situation, count(1) or count(my_column_name) does not
seem to make a dent. I understand that count(x) is useful for getting
the row count of a subset of results.  But since I just want the number
of rows in a table, shouldn't the query just be able to get this from a
value associated with this table?  Is this value maintained in the
sqlite code?
 
Buzz

Hennie Peters <[EMAIL PROTECTED]> wrote:
At 07:41 6-1-2004 -0800, Buzz Weetman wrote:
>I'm using sqlite in an embedded system. Disk I/O is relatively slow. I
>am doing a:
>SELECT count(*) FROM my_table;
>
>This is taking too much time. I've also tried count(1), as I saw
>suggested elsewhere in the mail list... though I'm not entirely sure
what 
>this means. 1st column? I've tried a column that I have an index for...

>not faster.
>
>Doesn't sqlite "know" the number of rows in each table without 
>explicitly
>counting them?
>
>Thanks for any help
>Buzz

The count function takes a column or a constant as an argument. I posted

the count(1) some days ago. I used this in
Oracle sql years ago. The idea was to make the query faster as it did
not 
need to scan the columns in the table.

groet,
Hennie
==================================================
Linux is like a wigwam - no gates, no windows and an apache inside.
==================================================


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to