Faced a problem when sampling a large amount of data.
As it turned out, Laravel connects the tables through the IN
operator, which is not very good when sampling> 1M. Model::with('user')
we get something like id in (1,2,3, ... 1000000)
Example: There is a table of users of the form 'id', 'name', 'email', 'number', 'bdate'
. Each user can have several projects in the system 'id', 'user_id', 'title', 'data', 'price', 'mode'
user_id
index field
need to select all users and their projects. Let the model look like this:
class User extends Model { protected $table = 'users' public function project() { return $this->hasMany('App/Project', 'user_id', 'id'); } }
What are the workarounds?
Yes, you can write the request yourself with pagination and handle this for example 50,000 each. Is it possible to do this with laravel means when describing the connection of the model.
where()
orjoin()
not an option? - VenZell