We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Very slow model fetching from relation

Hi all, I'm experiencing a performance issue inside models: when I use a relation to get the related objects of a model loading times begin to rise a lot. I need suggestions to debug these behaviour and find a faster solution.

Let's try to simplify my case in order to explain you. I have a structure like this: Robot RobotParts RobotPartsComponents

All the relations are one to many. There are other "hasOne" relations but I don't think they are usefull now for the example. I need to extract all RobotParts (filtered of course), with Robots infos and related RobotPartsComponents. When i use the getRobotPartsComponents relation the time of this operation becomes very very long. At the moment Robot and RobotParts are retrieved by a unique join query with queryBuilder



43.9k

Hi,

you should have a look at: database profiling tool

if you log the sql statements you could then try the request directly in sql and the see if it's really a phalcon related problem.