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
This commit is contained in:
hengsin 2020-07-31 23:56:41 +08:00 committed by GitHub
parent 20322a2b9d
commit ed740c05d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 5 deletions

View File

@ -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;