Support the ongoing development of Laravel.io →
Database Eloquent Architecture
Last updated 1 year ago.
0

Okay, I didn't think this through. It's not the hasManyThrough() method, it is Eloquent itself. I have about 2500 results from total of 360 000 records. I have indexes for the fields I need, the query is executing for about 100-200ms on Windows. I think the problem is when Eloquent builds the collections... anyone had this problem before ?

Last updated 1 year ago.
0

I think this works like eager loading... and I have written that doing big WHEREIN queries is bad practice. But I am not sure, I am not an expert, I have just read it in different websites... And some friend told me the same. May be you should use JOIN, Model::.....->join()->

Last updated 1 year ago.
0

Thanks, but I already tried Model::join()->..... and it's the same result. Guess the query builder works the same way. And if someone can provide an alternative to big whereIn() queries I'll be glad to hear it :)

Last updated 1 year ago.
0

I found a solution. Don't know if it's the best. I used simple DB::table() with joins to do the trick.

Last updated 1 year ago.
0

Just wondering what kind of objects did you get back? Was it collection with arrays or correspondig model instances?

Thanks.

Last updated 1 year ago.
0

No guessing if this is applicable or obvious, but are you guys using ->take(30), ->skip(30), ->paginate(30), or ->chunk(30,function($models){...}()) on any of your hard queries?

Last updated 1 year ago.
0

I have used chunk for a few queries where I had north of 30k results with each having more than 20 fields with strings, texts etc...

Paginate employs take() & skip() both !1

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.