Я использую laravel 5.6 для создания API для моего сайта.Но реакция API медленная, и загрузка займет около 16 секунд.Как я могу увеличить скорость ответа API?Я выполняю ниже операций SQL внутри вызова API
$master_data = DB::table('native_visitors_main AS nvm')
->leftJoin('ad_campaigns AS ac','ac.id','=','nvm.ad_campaign_id')
->select(
'ac.id as campaign_id',
'ac.campaign_name as campaign_name',
'nvm.current_cpc as cpc',
DB::raw("SUM(CASE WHEN nvm.gmt_time BETWEEN '".$start_date."' and '".$end_date."' THEN 1 ELSE 0 END) as total_click"),
DB::raw("SUM(CASE WHEN nvm.is_unique > 0 AND nvm.gmt_time BETWEEN '".$start_date."' and '".$end_date."' THEN 1 ELSE 0 END) as unique_click"),
DB::raw("SUM(CASE WHEN nvm.is_unique > 0 AND nvm.pixel_status!='' AND nvm.gmt_time BETWEEN '".$start_date."' and '".$end_date."' THEN 1 ELSE 0 END) as ap_click"),
DB::raw("SUM(CASE WHEN nvm.pixel_status IN('TY','cake') AND nvm.pixel_fired_on BETWEEN '".$start_date."' and '".$end_date."' THEN 1 ELSE 0 END) as result"),
DB::raw("SUM(CASE WHEN nvm.is_unique > 0 AND nvm.pixel_status IN('LP','TY','cake') AND nvm.pixel_fired_on BETWEEN '".$start_date."' and '".$end_date."' THEN 1 ELSE 0 END) as lp_clicks"),
DB::raw("ROUND(SUM(CASE WHEN nvm.gmt_time BETWEEN '".$start_date."' and '".$end_date."' THEN nvm.current_cpc ELSE 0 END ),2) as total_cpc")
)
->groupBy('ac.id')
->havingRaw("total_click >0")
->havingRaw("campaign_name != ''")
->get();