Osclass 8.3 brings a lot of new functions including optimized data loader functions those avoid excessive and repetitive database queries and store them into session for possible repetitive use, sort or filter.
How it works? Let's analyze it:
$data = Country::newInstance()->listAll(); $row = Country::newInstance()->findByCode('US');This was pretty fast, but what if we need that on 50 different files? And what if we need just one country? Or we have 20 queries getting country-level data - country by country? ... this leads to many repetitive database calls. Some can be optimized by using database cache like memcached, but some of them not.
What can we do about it? Use optimized way to access data:
$data = osc_get_countries(); $row = osc_get_country_row('US');We have such functions for most of data - country, region, city, category, user, ... In many cases, it's not possible to load everything into session as it's too much data and it would be slow.
For categories, there is also available constant OPTIMIZE_CATEGORIES (true/false) and OPTIMIZE_CATEGORIES_LIMIT (int) to enable/disable preloads into session. Default value is between 1000-2000 categories. If you use more, it's not going to preload everything.
Anyway, for objects like user, item... these are still going to be stored under their IDs, as when we received data for one item or user from DB, why not to store it for possible reuse? Especially for premium items or logged user record it's going to save a lot of queries.
Use optimized functions anywhere it's possible to reduce database queries, review helper files for list of supported functions in your current Osclass installation.