Hi,
I am trying to fetch ALL rows from a table in my dB. I need to get all rows because the data is displayed in a DataTable and then I am allowing people to filter through the rankings.
The script isn't even completing. I just get a white screen: http://clashdata.tk/clans/orderby/warswon/load
This is the Code:
public function warswonload(){
$count = Clans::count();
DB::statement(DB::raw("SET @rownum = 0"));
$sql = "@rownum := @rownum+1 AS rank, id, clanid, name, location, level, exp, warslost, warstied, warwinpercent, warswon, playercount, score";
$clan = Clans::orderBy('warswon', 'DESC')
->selectRaw($sql)
->get();
return [
'draw' => 1,
'recordsTotal' => $count,
'recordsFiltered' => count($clan),
'data' => $clan,
];
}
What can I do to get this to have all the results returned within seconds?
I did this on MySql command line through SSH and it took 26.55 seconds for the query to complete.
There are ~157K rows altogether.
Thanks!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community