Closed pixelspark closed 8 months ago
I think we should move those other fields to their separate tables. Then it's a matter of (not) preloading those associations.
I was working on this earlier, but didn't get it right yet.
Check this PR: #26
Yes, that looks nice :+1:
It appears Data
can also get quite heavy, you might want to move that out of the way as well (and only have some basic statistics in the main workouts
table derived from it).
I am not sure if gorm supports it but you might be able to utilize SQLite JSON functionality (possibly with virtual columns and even indexes on that?) to implement this. (Then again you also want to support other databases)
The plan was to get data out of the way, but that one is a little harder; I wanted to test with the easier column first 😄
When loading the workout list, the app fetches basically the full
workouts
table including all GPX data. This seems a bit unnecessary and also is very slow. This PR fixes it partially by omitting certain fields. However, theData
field is still quite large (while the list only uses some statistics). Further work should probaby be done to split theData
field into aDetails
field (containing e.g. all the points) and aStatistics
field containing the basic stats.This change makes the query a full second faster on my data set (~400 workouts).
Before:
After: