SQLite Forum

Approximate COUNT(*) using sqlite_stat4
Login
People are starting to use SQLite as an open data publication format with projects such as [Datasette](https://datasette.io/examples). 

A lot of summary exploration of data involves running `COUNT` on various fields. However, SQLite always does a full table scan to resolve a COUNT— which can end up being very expensive and slow to run. 

SQLite already has the ability to run `ANALYZE` and store statistics about the various tables and indices in sqlite_stat4 and sqlite_stat1. In the data publishing situation, it's reasonable to expect that `ANALYZE` has been run and all the gathered statistics are up-to-date. 

My question is whether nor not there are any plans (or any strong objections to) to addding a `PRAGMA approximate_count` that would make `COUNT` return estimates from the sqlite_stat tables instead of running a full table scan. 

Additionally, I'd appreciate pointers for how to get started if one were trying to implement this feature themselves.