gotosocial
gotosocial copied to clipboard
[performance] fetch only bare models from the DB when acquiring related models
When fetching related models within the database to flesh out an object, e.g. fetching the account author for a status, we should only fetch the barebones model. If we make a full call to db.GetAccountByID()
within some db.GetStatus___()
function then we will be populating the status with a fully-flesh-out account model. Which in the process might make further calls to other database functions in fleshing the account out...
Instead, we only want to fetch the bare bones equivalent for these models. In the worst case scenario (i.e. nothing cached) it will prevent multiple database calls fetching out fully fleshed out objects that may not be needed, and even in the best case scenario (everything cached) it will add more contention to every cache mutex that we hit in order to fetch a model.
An example of this in action can be seen here: TBD (waiting on #1085 to be merged)
Before this issue can be fully closed, it is reliant on #1094 being completed, but should be taken into account when completing the separate steps as a part of that issue.