-
Couldn't load subscription status.
- Fork 36
Description
I saw that achievement generation is quite inefficient when it comes to database usage.
The culprit is getModel method that is called 3 times for each achievement progress modification:
- in constructor
- in
getOrCreateProgressForAchieverto fetch achievement id - in
getOrCreateProgressForAchieverto associate newly created progress with details model
Then in this getModel method we have 2 database calls: read and save
That makes 6 database calls (8 if there is an update) for each achievement update.
My suggestion would be to make a dedicated command for synchronizing achievement details with database and remove save call from getModel as well as getModel call from constructor (possibly as a config option for backword compatibility) .
An extra improvement would be to reuse results of getModel instead of calling it each time.
Another suggestion would be to add an option for having stable ids
(eg. calculated from md5 of achievement fully qualified class name or just provided by user)
and assume that those will match model's id,
but that is something to be discussed
and since its a super breaking change, definitely require a config option.