我正在加载一个视图,其中包含大型SQL查询的结果,需要10秒才能加载。它涉及用户,因为服务器似乎没有响应。
我可以使用SQL占位符加载视图,并在加载视图后在页面上加载SQL结果吗?
//web.php route
Route::get('/results', 'ProgramController@showResults');
//ProgramController@showResults
public function showResults() {
$vw = Cache::remember('vwResultsCache',3,function(){
return $query = DB::table('vwResults')->first();
});
$count1 = $vw->count1;
$count2 = $vw->count2;
$count3 = $vw->count3;
return view ('backend.results', compact('count1','count2','count3'));
}
//backend.results view
<span> Welcome to the page</span>
<tbody>
<tr>
{{--count1--}}
<td>
{{$count1}}
</td>
{{--count2--}}
<td>
{{$count2}}
</td>
{{--count3--}}
<td>
{{$count3}}
</td>
</tr>
</tbody>