Something else is wrong. That is NOT a large amount of data.
Are you checking what queries actually get run (in your sql log or with debug bar)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have 3 tables.
The first table delivery_order has all my client data, the second table accounts has payment records for clients from the first table. The third table printed_jobs has records for printed jobs after a customer has paid for their order (meaning their records exists in accounts table).
I want to perform a query to fetch ALL orders that have been paid BUT NOT printed yet.
Both of these approaches take a lot of time (more than 3mins).
1. $dos = DB::table('delivery_orders')
->select('delivery_orders.*')
->leftJoin('accounts', 'accounts.do_id', '=', 'delivery_orders.id')
->leftJoin('printed_jobs', 'printed_jobs.do_id', '=', 'delivery_orders.id')
->whereNull('printed_jobs.do_id')
->get();
2. $dos = DeliveryOrder::has('accounts')->doesntHave('printed_job')->get();
What is the best way to load these data very fast, like up to 5-10 seconds?
Please or to participate in this conversation.