samedi 9 février 2019

How to optimize Query for larevel

I have more than 60k records and I use Has() to get records by relation ship but it slow more than 5s with pagination and 2s for query.

$products = Item::has('product_save');

my query :

select * from `products` where exists (select * from `product_saves` where `products`.`id` = `product_saves`.`product_id` and `user_id` = 2)

I use Item to do same condition and filter by where() . like is product still active or no price between 5 and 88...

any way to optimaze it? I added index in table but is still slow.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire