porter
porter copied to clipboard
Move database initialization overhead into an init function
There are activities that we run on every CLI command, that are not zero cost:
- Check the schema of the current database and determining if a migration is needed
- Ensuring indices are created on the current database
We could keep a file in PORTER_HOME that indicates if these tasks have been performed for the current storage configuration (hashed so that if the config changes, we repeat the check), and lets us only do this setup once per storage backend. This would save us 4 db calls per CLI command, which depending on the connection speed is ~1-2 seconds.
# ~/.porter/cache/init.json
storage:
CONNECTION_HASH:
schema: # insert the schema from the database
indices: # hash of indices
# maybe check once an hour or something, a TTL on the check essentially
This change should be made on the v1 branch.
Don't forget to repeat the cosmosdb performance tests to verify that this brings performance back to acceptable levels.