Eager loading an entire relation to display one field from the most recent row is a hydration of every row in that relation, per parent.
// loads every order line for every order
$orders = Order::with('lines')->get();
// {{ $order->lines->last()->shipped_at }}
// 6.0: one column, computed in the query
$orders = Order::addSelect(['last_shipped_at' => OrderLine::select('shipped_at')
->whereColumn('order_id', 'orders.id')
->latest('shipped_at')
->limit(1)
])->get();
The result is a plain attribute on the model, so the template is unchanged and nothing is hydrated. It needs an index that supports the correlated lookup — (order_id, shipped_at) here — and without it the subquery runs once per row and is worse than the eager load it replaced. orderByLeftPowerJoins-style tricks are not needed; the same subquery can be used in orderBy, which is the case that previously forced a join and a GROUP BY.