Hi team,
Feature(s) impacted
I open this ticket as I have noticed some useless queries that are generated in some circumstances.
This can have an impact on performances, so I hope you will have some time to investigate.
I have recorded a video (link below) to illustrate the issue.
Observed behavior
I have a users
collection, with several associations. The problem I detected concerns hasOne relationships.
db.users.hasOne(db.cards, { scope: { current: true }, foreignKey: 'user_id' });
db.users.hasOne(db.kyc, { foreignKey: 'user_id' });
What is working well
When I access one specific record of the parent users
collection, everything is working fine. I am getting all dependent information on associated collections (cards
and kyc
), and no useless query is generated (video up to 1:30).
Erroneous behaviour
At 1:30 in the video: I come back to the initial list of users
At 1:38 => I click on the card
link.
when I access the card
information of the same specific record, I can see in the log that 2 useless queries are generated. Here are the different routes called in this order:
- GET /cards/:id
- GET /cards/:id/relationships/old_cards
** GET /forest/cards - GET /cards/:id/relationships/old_cards/count
** GET /forest/cards/count
The two routes highlighted in Bold here above should not be called!
It generates a request to read 20 records (our current pagesize) of the cards
collection. There is no reason to do that.
At 2:15: I come back to the users
list
At 2:21: I click on the kyc
link
We have the same issue.
Here are the different routes called in this order:
- GET /forest/kyc/:recordId
** GET /forest/kyc
** GET /forest/kyc/count - GET /kyc/:id/relationships/kycDocuments/count
- GET /kyc/:id/relationships/kycDocuments
The two routes highlighted in Bold here above should not be called!
It generates a request to read 20 records (our current pagesize) of the kyc
collection. There is no reason to do that.
Expected behavior
As explained above, useless queries have an impact on performances, and should not be done.
Failure Logs
Important note: In order to be sure that this is not my code that generates the issue, I have commented my overridden routes, and my Sequelize hooks, and generated the same issue with it.
Please find attached the associated logs without my overridden routes.
- The first file in the zip is the one illustrated in the video
- The second one is the same issue reproduced without hooks, and without overridden routes.
forest_logs_dev_20220816.zip (3.3 KB)
Context
- Project name: MyPocket
- Team name: Compliance
- Environment name: Development (but the problem can be reproduced in any environment)
- Agent type & version:
"liana": "forest-express-sequelize",
"liana_version": "8.5.11",
"stack": {
"database_type": "multiple",
"engine": "nodejs",
"engine_version": "14.17.0",
"orm_version": "5.22.3"
}
}
- Recent changes made on your end if any: I think that this is a very old issue that has always been present. I have recently upgraded my liana version in order to be sure that the same issue persists in last release.