-
-
Notifications
You must be signed in to change notification settings - Fork 120
Research how much of a difference analyze / sqlite_stat1 makes #369
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'll start by running some experiments against the 11MB database file from https://global-power-plants.datasettes.com/global-power-plants.db |
|
|
Basically no difference using this very basic benchmark:
I should try this against a much larger database. https://covid-19.datasettes.com/covid.db is 879MB. |
Didn't manage to spot a meaningful difference with that database either:
Maybe |
There are some clues as to what effect ANALYZE has in https://www.sqlite.org/optoverview.html Some quotes:
And
And
|
EXPLAIN QUERY PLAN select country_long, count(*) from [global-power-plants] group by country_long
|
This is probably too fancy. I think maybe the way to do this is with Here's the explain for that: https://global-power-plants.datasettes.com/global-power-plants?sql=EXPLAIN+QUERY+PLAN+select+*+from+[global-power-plants]+where+%22country_long%22+%3D+%27United+Kingdom%27 |
I think the query that will help solve this is:
In this case, the query planner needs to decide if it should use the index for the
Those numbers are explained by this comment in the SQLite C code: https://github.com/sqlite/sqlite/blob/5622c7f97106314719740098cf0854e7eaa81802/src/analyze.c#L41-L55
So that table is telling us that using a value in the Just one catch: against both my |
Closing this - it was something I was curious about, but evidently not curious enough to actually do the work! |
Uh oh!
There was an error while loading. Please reload this page.
Originally posted by @simonw in #365 (comment)
More generally: how much of a difference does the
sqlite_stat1
table created byANALYZE
make to queries?I'm particularly interested in
group by
/count *
queries since Datasette uses those for faceting.The text was updated successfully, but these errors were encountered: