Hi Eric,

If you have the dbstat module enabled (-DSQLITE_ENABLE_DBSTAT_VTAB), you
can query the dbstat virtual table for the number of pages used per table
and index, e.g.

    SELECT name, COUNT(path) AS pages FROM dbstat GROUP BY name ORDER BY
pages DESC;

This runs in ~600 ms on one of my applications, which isn't that fast, but
I've had success placing the read on a background thread.  (Out of
curiosity, how quick do you need the report to be?)

The dbstat virtual table manual (https://www.sqlite.org/dbstat.html) has
some more examples and a longer description of the contents of the dbstat
table.

- David

On Mon, Jul 30, 2018 at 1:46 AM, Eric Grange <zar...@gmail.com> wrote:

> Hi,
>
> Is there a quick way (as in speed) to obtain the number of database blocks
> (or kilobytes) allocated for each table and each index ?
>
> I have been using various manual approaches so far (from using length() to
> vacuum and drops), but none of them are really fast
> or can practical to automate.
>
> Eric
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@mailinglists.sqlite.org
> http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to