我有表更加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 –