dogsheep / healthkit-to-sqlite

Convert an Apple Healthkit export zip to a SQLite database
https://datasette.io/tools/healthkit-to-sqlite
Apache License 2.0
199 stars 9 forks source link

Add index on workout_points.date #20

Open simonw opened 3 years ago

simonw commented 3 years ago

Sorting that by date makes sense for seeing most recent points, and my DB has 2.5m points in so it's an expensive sort!

simonw commented 3 years ago

Workaround:

sqlite-utils create-index healthkit.db workout_points -- -date

See https://sqlite-utils.datasette.io/en/stable/cli.html#creating-indexes

simonw commented 3 years ago

Also on workout_points.workout_id to speed up queries to show all points in a specific workout.