IDEMPIERE-3654 1008749 Fix performance issue with bpartner field callout.

This commit is contained in:
Carlos Ruiz 2017-12-15 14:17:21 +01:00
parent ad868d100c
commit 4aac55cca2
3 changed files with 8 additions and 12 deletions

View File

@ -135,12 +135,11 @@ public class CalloutInvoice extends CalloutEngine
+ " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference," + " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,"
+ " p.SO_Description,p.IsDiscountPrinted," + " p.SO_Description,p.IsDiscountPrinted,"
+ " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," + " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
+ " l.C_BPartner_Location_ID,c.AD_User_ID," + " (select max(lbill.C_BPartner_Location_ID) from C_BPartner_Location lbill where p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.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,"
+ " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID, p.SalesRep_ID " + " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID, p.SalesRep_ID "
+ "FROM C_BPartner p" + "FROM C_BPartner p"
+ " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)" + " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)"
+ " LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')"
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID AND c.IsActive='Y') "
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1 + "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");

View File

@ -83,12 +83,11 @@ public class CalloutInvoiceBatch extends CalloutEngine
+ " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference," + " COALESCE(p.M_PriceList_ID,g.M_PriceList_ID) AS M_PriceList_ID, p.PaymentRule,p.POReference,"
+ " p.SO_Description,p.IsDiscountPrinted," + " p.SO_Description,p.IsDiscountPrinted,"
+ " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," + " p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
+ " l.C_BPartner_Location_ID,c.AD_User_ID," + " (select max(lbill.C_BPartner_Location_ID) from C_BPartner_Location lbill where p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.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,"
+ " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID " + " COALESCE(p.PO_PriceList_ID,g.PO_PriceList_ID) AS PO_PriceList_ID, p.PaymentRulePO,p.PO_PaymentTerm_ID "
+ "FROM C_BPartner p" + "FROM C_BPartner p"
+ " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)" + " INNER JOIN C_BP_Group g ON (p.C_BP_Group_ID=g.C_BP_Group_ID)"
+ " LEFT OUTER JOIN C_BPartner_Location l ON (p.C_BPartner_ID=l.C_BPartner_ID AND l.IsBillTo='Y' AND l.IsActive='Y')"
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID) "
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1 + "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y"); boolean IsSOTrx = Env.getContext(ctx, WindowNo, "IsSOTrx").equals("Y");

View File

@ -464,12 +464,10 @@ public class CalloutOrder extends CalloutEngine
+ "p.SO_Description,p.IsDiscountPrinted," + "p.SO_Description,p.IsDiscountPrinted,"
+ "p.InvoiceRule,p.DeliveryRule,p.FreightCostRule,DeliveryViaRule," + "p.InvoiceRule,p.DeliveryRule,p.FreightCostRule,DeliveryViaRule,"
+ "p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable," + "p.SO_CreditLimit, p.SO_CreditLimit-p.SO_CreditUsed AS CreditAvailable,"
+ "c.AD_User_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,"
+ "p.PO_PriceList_ID, p.PaymentRulePO, p.PO_PaymentTerm_ID," + "p.PO_PriceList_ID, p.PaymentRulePO, p.PO_PaymentTerm_ID,"
+ "lbill.C_BPartner_Location_ID AS Bill_Location_ID " + "(select max(lbill.C_BPartner_Location_ID) from C_BPartner_Location lbill where p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.IsActive='Y') AS Bill_Location_ID "
+ "FROM C_BPartner p " + "FROM C_BPartner p "
+ " LEFT OUTER JOIN C_BPartner_Location lbill ON (p.C_BPartner_ID=lbill.C_BPartner_ID AND lbill.IsBillTo='Y' AND lbill.IsActive='Y')"
+ " LEFT OUTER JOIN AD_User c ON (p.C_BPartner_ID=c.C_BPartner_ID AND c.IsActive='Y') "
+ "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1 + "WHERE p.C_BPartner_ID=? AND p.IsActive='Y'"; // #1
boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx")); boolean IsSOTrx = "Y".equals(Env.getContext(ctx, WindowNo, "IsSOTrx"));