Level 102
Why? What do you need the data for? I dont assume you want to show 10,000 products in a page?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i have a query where i want to load 10,000 products from the table. then every product hasmany categories ln a category table with the columname of name.
$basicObjects = DB::table('products')
->leftjoin('assortments', 'assortments.product_id', '=', 'products.id')
->leftjoin('prices', 'prices.product_id', '=', 'products.id')
->leftjoin('stocks', 'stocks.product_id', '=', 'products.id')
->leftjoin('retail_prices', 'retail_prices.product_id', '=', 'products.id')
->leftjoin('categories as cat1', 'cat1.product_id', '=', 'products.id')
->leftjoin('categories as cat2', 'cat2.product_id', '=', 'products.id')
->leftjoin('categories as cat3', 'cat3.product_id', '=', 'products.id')
->leftjoin('categories as cat4', 'cat4.product_id', '=', 'products.id')
->leftjoin('categories as cat5', 'cat5.product_id', '=', 'products.id')
->where(function ($query) {
$query
->where('products.ecom', '=', true)
->where('products.enabled', '=', true)
->where('prices.quantity', '=', 1)
->where('prices.pricelist_id', '=', 1)
->where('retail_prices.country_id', '=', 164);
})->orwhere(function ($query) {
$query
->where('cat1.country_id', '=', 164)
->where('cat1.sorting', '=', 1);
})
the problem with above is it gets slow realy fast to 60 seconds. ->orwhere(function ($query) { $query ->where('cat2.country_id', '=', 164) ->where('cat2.sorting', '=', 2); })
Please or to participate in this conversation.