我有表更加50000条记录。多对多关系。Laravel 5雄辩块数据
记录模式:
public function busines(){
return $this->belongsToMany('App\Busines', 'busines_record', 'record_id', 'busines_id');
}
商业营业模式:
public function records()
{
return $this->belongsToMany('App\Record', 'record_id');
}
我的查询:
$data = Records::with('busines')->where('show', '=', 1)->get();
查询执行长。如何优化查询?
尝试增加基本指标到'show'领域。 https://laravel.com/docs/5.2/migrations#creating-indexes –