From ed740c05d7123c003c86dcf4dd44c66a0b1a3318 Mon Sep 17 00:00:00 2001 From: hengsin Date: Fri, 31 Jul 2020 23:56:41 +0800 Subject: [PATCH] IDEMPIERE-4383 Performance: CalloutInOut for bPartner field has bad performance for BP with many locations and contacts (#191) remove left join to bplocation and ad_user --- .../src/org/compiere/model/CalloutInOut.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java b/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java index bf9544d7b6..1ff8c06e30 100644 --- a/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java +++ b/org.adempiere.base.callout/src/org/compiere/model/CalloutInOut.java @@ -271,11 +271,10 @@ public class CalloutInOut extends CalloutEngine + "p.M_PriceList_ID,p.PaymentRule,p.POReference," + "p.SO_Description,p.IsDiscountPrinted," + "p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," - + "l.C_BPartner_Location_ID,c.AD_User_ID " - + "FROM C_BPartner p, C_BPartner_Location l, AD_User c " - + "WHERE l.IsActive='Y' AND p.C_BPartner_ID=l.C_BPartner_ID(+)" - + " AND p.C_BPartner_ID=c.C_BPartner_ID(+)" - + " AND p.C_BPartner_ID=?"; // 1 + + "(select max(l.C_BPartner_Location_ID) from C_BPartner_Location l where p.C_BPartner_ID=l.C_BPartner_ID AND l.IsActive='Y') as C_BPartner_Location_ID," + + "(select max(c.AD_User_ID) from AD_User c where p.C_BPartner_ID=c.C_BPartner_ID AND c.IsActive='Y') as AD_User_ID " + + "FROM C_BPartner p " + + "WHERE p.C_BPartner_ID=?"; // 1 PreparedStatement pstmt = null; ResultSet rs = null;