Repository navigation
Conversation
This speeds up account creation by ~50% on HDD.
| paramsv![], | ||
| ) | ||
| .await?; | ||
| if !sql.table_exists("config").await? |
There was a problem hiding this comment.
These checks are dropped, because execute_batch should fail if some table is not created.
|
Related benchmark PR: #1882 |
flub
left a comment
There was a problem hiding this comment.
Is it possible to further split up this function so that you don't have to go through all if branches if you just created the table? I imagine we would always keep the final structure in the batch create and can thus skip all the migrations when you start from scratch.
it also means any schema changes need two code-path's to check though. i wonder if it's feasible to run the entire test-suite using both the create branch and the migration branch?
|
Going through all the comparisons should be almost instant, it is just comparing integers in memory. I think the main problem was
There is no way to trigger migration path now. It is also possible to continue adding migrations without changing |
i would also go that way, it will probably take some time until it is slow again (the summed up migrations are the result of 3 years!) maintaining create-path and upgrade-path all the time together will easily result in overseen errors that are also hard to fix as already in the db of the users then; with the current migration-if-branches otoh we have no issues in all the years iirc. btw, also on a mac pro ssd from 2017, performance increases by 50% - however, on another level, from 60ms to 27ms - but on cheap ssd build into cheap android phones that will probably an higher absolute win :) |
|
for testing create-code-paths as well as update-code-paths: maybe we can write a test that (1) opens an "old" database file as of dbversion=0 from somewhere in the repo, (2) creates a new database, (3) checks that tables, columns, indexes in (1) and (2) are identical wrt existence. just an idea, not sure if that is really worth the effort, probably there are other tests that are more urgently missing :) |
r10s
left a comment
There was a problem hiding this comment.
compared all upgrade-code with the new squashed-table-creation, lgtm :)
I'm not sure how easy it is to do (3). I also agree that it's hard to test all corner cases. That's why my thinking was more to add a parameter which we can use in test code that forces to go the migration path. We could than add another CI run which enables this path with an env var or some other reasonable way. This way we could run the entire test suite twice, once with each db migration path. If (3) is not that a hard problem then it this would be a much cheaper options of course. |
|
just had a closer look on how to do (3): we could get a single string that lists all tables and all index-creation commands using the following commands: these two strings just have to be the same on upgrade-code and create-code. the sql-column for type=index should be identitcal, so we can use that- however, for the type=table, the sql-columns are not comparable between upgrade-code and create-code, there are different orders, spacing etc. so, to check that also all rows are identical, we have to iterate over all tables (using similar statement as above) and build a string from all rows, using so, all in all, it is some work, however, probably pretty straight-forward and not hard :) |

No description provided.