laravel has和 wherehas的性能问题 Veröffentlicht am 2016-11-30 #laravel orm 查询 奇慢无比。。。这是个坑啊 123$products = Product::whereHas('colors', function ($q) use ($id) { $q->where('photo', '<>', '')->where('colors.id', '=', $id);})->paginate(8); 改为SQL: 12$products = Product:: whereRaw('products.id in (select product_id from color_product where color_product.color_id = ? and color_product.photo <> "" )', [$id]);