-
-
Notifications
You must be signed in to change notification settings - Fork 858
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lazy Loading Faster than Eager loading? #2982
Comments
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
bump |
Sorry to bump again, but I'm really struggling with this issue. Any updates/workarounds? |
I think eager loading should be faster. Try reviewing the SQL generated by the package by inspecting the ajax request with APP_DEBUG=TRUE. You might be having an N+1 issue in your code. |
@yajra If you take a look at my original post its actually the opposite of that. |
@yajra I have also checked the queries (and everything else I could think of) thoroughly, and I'm using eager loading to fix the N+1 issue. However, as @chrismeats states, when I eager load the relationships, the queries are quick, but something else is taking a long time to load (the performance hit is sometimes worse than N+1 issue). |
Encountered something similar but the slow response was due to a binary(blob) field being included in the response. Removing the blob field in select SQL fixes the issue. Do any of you have blob fields? |
@yajra No blobs for me, I only have Edit: added |
Can you try removing the |
@yajra No blobs for me either |
I tested all the column types I have, However it appears that the more columns we eager load, the worse the performance becomes. |
@ardavan-ansari Have you been able to find any kind of fix or work around for this? |
Summary of problem or feature request
I have a simple product hasMany variants relationship.
I can not figure out a slow performance issue.
If I eager load my variants relationship:
$query->with('variants');
Performance takes a serious hit and takes 3-4 seconds to load the page. Even though debug bar does not show any slow queries. and all queries execute in about 131ms
If I remove that eager load and just do lazy loading, page loads in 522ms even though there are 100 lazy loaded, essentially duplicate, queries! all queries execute in about 237ms
The slow down seems to come sometime during call to
return $table->make(true);
I believe I have relevant code copied below. Thank you in advance for any help!
Code snippet of problem
System details
The text was updated successfully, but these errors were encountered: