From 2e3c1d6c0ac1295821266e467d2ee2e56b36df72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Fri, 15 Nov 2019 19:13:53 +0100 Subject: [PATCH] Fetch preview attachment directly in table query. This reduces the query count and therfore improves performance. --- src/DataTables/PartsDataTable.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index aa1c507d..626ff52e 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -82,10 +82,14 @@ class PartsDataTable implements DataTableTypeInterface ->addSelect('footprint') ->addSelect('manufacturer') ->addSelect('partUnit') + ->addSelect('master_picture_attachment') + ->addSelect('footprint_attachment') ->from(Part::class, 'part') ->leftJoin('part.category', 'category') + ->leftJoin('part.master_picture_attachment', 'master_picture_attachment') ->leftJoin('part.partLots', 'partLots') ->leftJoin('part.footprint', 'footprint') + ->leftJoin('footprint.master_picture_attachment', 'footprint_attachment') ->leftJoin('part.manufacturer', 'manufacturer') ->leftJoin('part.orderdetails', 'orderdetails') ->leftJoin('part.partUnit', 'partUnit');