Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hey @rsanchez, while using Deep we started to see pulling models for complex entries take a fairly significant amount of time to populate (on the order of 50 secs). I dove into the specifics of the addon and discovered that due, in part, to Eloquent that models are hydrating twice. See query log:
You'll see that there are 4 queries that repeat and this is due to the call to
$builder->getModels($columns)
and then later to$builder->getModel()->newCollection($models)
inBuilder.php::get()
. Both of these end up calling for anewCollection()
on the model which on the Entry model results in multiple calls to$this->hydrateCollection($collection)
.To fix this issue, I added a state check to the Collections which indicates if they have been hydrated. What this does is allows the call to
$builder->getModels($columns)
to do the initial hydration it needs to do, but skips it on the second pass while calling$builder->getModel()->newCollection($models)
. TheisHydrated()
method is not cached which would allow for any non-hydrated additions to the collection to classify the entire collection as unhydrated and would force another set up queries and population of the models.Let me know if there is anything further I can do here, but we saw it make a 50% speed improvement in our application. Thanks!