Open simonw opened 3 years ago
So how would this work?
I think I'm going to automatically use these values if the _counts
table exists, unless a ignore_counts_table
boolean setting has been set. I won't bother looking to see if the triggers have been created.
Should Datasette have subcommands for this? datasette enable-counts data.db
and datasette disable-counts data.db
and datasette reset-counts data.db
commands?
Maybe. The sqlite-utils
CLI tool could be used here instead, but that won't be easily available if Datasette was installed as a standalone binary or using brew install datasette
or pipx install datasette
.
sqlite-utils 3.2 now has a mechanism for creating a
_counts
table with triggers to maintain counts for individual tables. Datasette could look for this table and use it for counts, dramatically speeding up places that currently suffer from slow counts. Refs #859.https://sqlite-utils.datasette.io/en/stable/python-api.html#cached-table-counts-using-triggers