vendredi 16 avril 2021

Laravel optimize query

In my Database i hv column name type which contains the value Ship and Ship+ and status from 1 to 15 So if the value is Ship and check status value more than 8 and less than 13 if the value is Ship+ and check status value more than 8 and less than 15...So here how can i modify the below query to reduce the exection time.

    $start_time = microtime(true);
    CS::where('status','>', 8)->chunkById(100, function ($items) use (&$post) {
    foreach ($items as $item){
            $item= CS::where('awb', $item->awb)->first();

           
                $this->info('Status ' . $item->delivery);
                $this->info('Country` ' . $item->country_code);
      }
    });
    $end_time = microtime(true);
    $execution_time = ($end_time - $start_time);
    Log::info("total execution time=".'  '.$execution_time);


via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire