/
Slow performance, when mass-updating [5.2.2-B2]
Slow performance, when mass-updating [5.2.2-B2]
When there is a need to change one record in the database, then the "kDBItem" class is the way to go. Internally it uses "formatter classes" to transform human-readable data entered by the user into the format, that can be stored in the database and backward.
However, due to the fact, that the "kDBItem" class relies on the class factory to store instances of "formatter classes" there will be a performance penalty. This isn't a big deal, when updating one record in the database, but there will be issues when updating 100 records and more in one batch.
Solution
- introduce protected "kDBBase::getFormatter" method that would:
- cache previously retrieved formatter class into private static "$_formattersCache" property
- if formatter isn't found in above-defined cache, then get it from the factory and store it in the cache
- otherwise, return formatter from the case
- instead of doing "recallObject" to get formatter in the "kDBBase" and "kDBItem" classes use "kDBBase::getFormatter" method