Usually when my queries take that long it's because I'm not using indexes on the fields I am searching by.
If you don't have an index on 'AcctStartTime' you should try creating one.
To check what fields have indexes from tinker you can use
Is AcctStartTime a datetime? Like @shez1983 said you shouldn't use like with a date. The reason I believe is it requires additional conversion on every row and doesn't allow the index to work.
Try using.
@mattsplat
The AcctStartTime is a date. I'm searching through my DB with just the year and the month.
After reading what you both said i did the code like this:
$data = TopFiber::select(DB::raw('UserName, sum(AcctInputOctets) as Input , sum(AcctOutputOctets) as Output'))
->whereDate('AcctStartTime' , $data['date'])->groupBy('UserName')->orderBy('Output', 'desc')->limit(20)->get();