try not to group by uid which has a cost on performance
add index on stock.explanation_uid for Delivery.getTotalPrice(fast=1)