francois
253
14
Eloquent

eager loading and PHP (not MYSQL) performance issue

Posted 4 years ago by francois

Hello,

I was optimizing an app, where I need to export some data.

There is a query to export around 12 000 rows, but for all rows, there is 3 or 4 relations used.

When I execute the request excluding the relations data, export is build in less than 0.5s. But, when I add this relations (with eager loading, or not) in the export, request take more than 2 min.

I've looked at the server side, and mysql is not really overloaded, but apache is used at 100% on one thread during those 2 mins.

So, I think it's a php/Eloquent issue, and not from the request.

My question is : If a relations is declared in my php application (the Eloquent way), but I have not set the foreign key on the mysql side, may it generate performance issue for Eloquent, where Eloquent needs to test if the relation is set on active record etc ? Because I know I can use indexes, but we work on around 50 000 rows in our tables, so in can't explain this time difference.

Thanks

Please sign in or create an account to participate in this conversation.

Reply to

Use Markdown with GitHub-flavored code blocks.