Can this query be optimized because it takes very long time to display results even if there is only row in tables.
$orders = Order::select(DB::Raw('orders.*, payments.*'))
->leftJoin('payments', function($join) {
$join->on('orders.order_id', '=', 'payments.orderID')
->orwhere('payments.processed', '=', '');
})
->orderBy('order_id', 'asc')
->get();
So here I query table order and table payments. Condition must check if there is matching 'orders.order_id', '=', 'payments.orderID'. Then I show results on the page and select columns from both tables.
I have no idea why this work so slow and it takes like 10 seconds to load page and show just 1 result. Other parts of the site are fast even they must show a lot more results from other tables.