Support the ongoing development of Laravel.io →
Database Eloquent
Last updated 2 years ago.
0

I can't see the point in the query that you are doing; your returning an array of id that exist in the User table from $idList?

With that said, I would "stream" the request by breaking up $idList into batches of say 1000 ids, looping over those batches and running the query on each, appending the result to $userIdLists upon each iteration. Increase the batch size until you get the least amount of batches possible.

foreach (array_chunk($idList, 1000) as $idListBatch) {
    ...
}

There are better ways of doing this, but off the top of my head this is the one I can think of.

Last updated 2 years ago.
0

**** said:

Thanks man, good advice.

Last updated 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

niugege niugege Joined 28 Mar 2014

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.