Have you tried to paginate results?
Using count() with a large set of data
I have a database of around 75,000 records (!).
I would like to create a table where I can list out the records per country. Locally (homestead/vagrant) it works nicely, presumably as it has plenty of processing power.
With a smaller Digital Ocean box I am getting nginx errors (502) and have deduced this is because the query is quite inefficient.
So I am looking for some advice on how to architect this properly!
My view looks like so:
@foreach($countries as $country)
<tr>
<td>{{ $country->name }}</td>
<td class="right">{{ $country->subscribers->count() }}</td>
And (part of) my model (Country) looks like so:
public function subscribers()
{
return $this->hasMany('App\Subscriber')->where('enabled', '=', '1');
}
How would you recommend doing this? I'm not looking for complete solutions, just some pointers so that I can learn the right way.
Thanks very much
Please or to participate in this conversation.