Hi team,
Following the solution brought on the first performance issue I reported, I still have some performance issues generated by the fact that the smart fields of all associated relations are computed.
After analyzing the requests that are done when viewing my users
collection, I could confirm that all the smart fields of all the collections associated with the users
collection are computed.
And each one is computed 20 times (because I am displaying 20 lines per page).
Because many of them are requesting themselves information from the DB, I am getting a lot of requests: 20 times per smart field that need access to the DB.
Only for querying the smart fields of the associated collections (I mean without the main query retrieving the users
data), I have counted a total of 12 * 20 = 240 SQL requests
while it would need to query only 2 * 20 = 40 requests (because only two smart fields references are needed to query the DB).
Furthermore, even some smart fields of some relations that I am not displaying in the main users list are computed, while I am not using them.
Here the details of the associations with my users
collection, that I am using in the users list view:
// associations displayed in the users list view
db.users.hasOne(db.kyc);
db.users.hasOne(db.subscriptions);
db.users.hasOne(db.cards);
db.users.belongsTo(db.users, { as: ‘sponsor’, foreignKey: ‘sponsor_id’, targetKey: ‘id’ });
db.users.belongsTo(db.cod_countries_labels, { as: ‘Birth_country’, foreignKey: ‘birth_country’, targetKey: ‘country_code’ });
Columns used as Reference:
- in kyc: smart field
- in subscription: smart field
- in cards: smart field
- in cod_countries_labels: native SQL field
- in users (for the sponsor): smart field
When displaying the users list, here is what I noticed:
- all the 18 smart fields of the
kyc
collection are computed - the smart field if the
subscriptions
collection is unique and computed as needed - all the 5 smart fields on the
cards
collection are computed - the smart field of my
addresses
collection is computed (it is a hasMany between users and addresses, so I don’t know why) - all the 9 smart fields of my users collection are computed, while they are not all needed in the same view
This last point is also important: when displaying a list, all native fields of the list are retrieved from the DB, and all the smart fields of this list are always computed, even if only some columns are displayed.
So all these data and computations are generating lots of useless traffic, loads, memory occupation, and are really impacting Forest admin global performances.
We have some users that are using Forest admin all the day as their main working tool.
The displayed columns are optimized for their day to day needs, and they are becoming impatient.
So I am facing a real challenge to optimize Forest and I really do not know how I could do this.
I hope you will be able to dig into that issue for a whole performance improvement.
Thanks in advance for your help.
Here is my last setup:
"meta": {
"database_type": "postgres",
"liana": "forest-express-sequelize",
"liana_version": "6.3.11",
"engine": "nodejs",
"engine_version": "12.13.1",
"framework": "express",
"framework_version": "^4.17.1",
"orm_version": "4.44.0"
}