dimanche 3 février 2019

Laravel collection count() takes too long

I have a contacts table and a contact_list table, a contact_list has many contacts, contacts table has a is_active field.

enter image description here

to get the number of active contacts for a contact_list i use the query builder as follows:

$contact_list->contacts()->where('is_active', 1)->count();

if the number of contacts is too big the query takes too long. is there a better way to implement this?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire