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

Is Relationship increase load on mySql

If I used relation in model like belongsTo, hasMany etc. in model and use object to get matched data from another table. Will it increase load on mySql Server, Since it call single query for each result from resultset

But Suppose I have multiple Hats and each Hats have ribbons. So If I queried for hats only then will it queried for each ribbons inside each hats when I used object of ribbons? e.g. I have 10 hats and each 10 hats have 2 ribbons, and I m using ribbons object each time while diplay. Then will it call 1 query for hats and 20 queries for ribbons. So will it not increase request to database. So it is preferrable method?



1.4k
Accepted
answer

You can write join query, so that you have to execute only one query. You will get your hat and its ribbons in one query