samedi 2 février 2019

How can i optimize the laravel Query it takes long time?

In here TableA and result is almost 700k Data.But in near future is cross the 1000k. data_a count all matching data to match column with text

  $accessories_count_all = TableA::count();
  $data_all = TableB::orderBy('id','desc')->paginate(16);
  $name = [];
  foreach ($data_all->chunk(5000) as $data) {
     foreach ($data as $value) {
        $data_a = DB::table('result')
               ->where('column','text')
               ->count();          
      $per_list = [
              'count_data'=>$data_a,
             'view_name'=>$value->view_name,
        ];
     array_push($name, $per_list); 
   }
 }
 $per_var_count = $name;

I am try to optimize the query using chunk.But it takes long time that why the server is time out. Please suggest me which is the best way to handle this query using large data set.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire