> > Hi,
> > I want to check the record count of a table every 5 seconds.
> > It seems there's only one way to get a table's record count:
> > select coun(*) from ATable
> > 

> 
> Create a separate table that has a single row and single 
> column for storing the record count:
> 
>     CREATE TABLE reccount(cnt INTEGER);
> 
> Then create triggers that fire on every insert or delete and 
> update the record count table.
> 
>     CREATE TRIGGER rc1 AFTER INSERT ON tableA BEGIN
>       UPDATE reccount SET cnt=cnt+1;
>     END;
>     CREATE TRIGGER rc2 AFTER DELETE ON tableA BEGIN
>       UPDATE reccount SET cnt=cnt-1;
>     END;
> 
> Then to get the record count do:
> 
>    SELECT cnt FROM reccount;
> 
> --
> D. Richard Hipp  <[EMAIL PROTECTED]>
> 

I've noticed this question has been raised a few times in the past and
the workaround proposed is to create a "count" table to eliminate the
need to do a table scan. I was wondering whether it is worth adding this
feature to Sqlite so that a call to "select count(*)... " (which is not
restricted with a WHERE clause) is retrieved from an internal "count"
table? i.e. this performance workaround is part of the core sqlite code.

Just an idea.

Regards
Nick

********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to