There are several things to think about in this kind of a query --

On 6/18/08, Stefan Arentz <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 11:51 AM, Scott Baker <[EMAIL PROTECTED]> wrote:
>  > Stefan Arentz wrote:
>  >> Is it possible to get the size of a table without running a count(*)
>  >> query on it?

By "size" you really mean the number of rows in a specific table in
the db. Size (on disk) has nothing to do with the number of rows, just
so we get the terminology clear.

That said, how on earth can you count something without counting it?
No db can do that magic. Someone, somewhere, somehow, sometime has to
do the count.


> Even an approximated size would be good for me.
>  >> PostgreSQL has this value in a system table. Does SQLite have
>  >> something similar?
>  >
>  > What wrong with running SELECT count(*) it should be very fast.
>
>
> It seems to run a full table scan. I have 10+ million rows.
>

Well, seems like you already have an approximate count when you say
10+ million rows.

The SQLite creators have chosen not to implement an efficient count
mechanism as they see that as something that can be easily implemented
by those who want/need it, and for others, and for them, there is less
cruft to maintain.

If you know C, and want to create this functionality, feel free to do
so. I am sure many other folks will love you for it.

Until then, it really is trivial to write a couple of TRIGGERs that
maintain a db-wide count_of_rows table.

Just search the archives... this has been suggested many times.


>
>   S.
>
> _______________________________________________
>  sqlite-users mailing list
>  sqlite-users@sqlite.org
>  http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>


-- 
Puneet Kishor http://punkish.eidesis.org/
Nelson Institute for Environmental Studies http://www.nelson.wisc.edu/
Open Source Geospatial Foundation (OSGeo) http://www.osgeo.org/
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to