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);


from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/3e0IGqw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire