Fixes Issue 39305:Performance issue in c_bpartner_trg on environment
authorAtul Gaware <atul.gaware@openbravo.com>
Thu, 27 Sep 2018 00:00:16 +0530
changeset 34824 463468c986a3
parent 34823 58e108f901e1
child 34825 a55bab8b0e2f
Fixes Issue 39305:Performance issue in c_bpartner_trg on environment
with lots of data

** Made use of fin_payment_bpartner_credit index in query
to fetch curreny of the generated credit not yet consumed
in c_bpartner_trg.
src-db/database/model/triggers/C_BPARTNER_TRG.xml
--- a/src-db/database/model/triggers/C_BPARTNER_TRG.xml	Thu Sep 27 14:26:32 2018 +0000
+++ b/src-db/database/model/triggers/C_BPARTNER_TRG.xml	Thu Sep 27 00:00:16 2018 +0530
@@ -17,7 +17,7 @@
   * parts created by ComPiere are Copyright (C) ComPiere, Inc.;
   * All Rights Reserved.
   * Contributor(s): Openbravo SLU
-  * Contributions are Copyright (C) 2001-2016 Openbravo, S.L.U.
+  * Contributions are Copyright (C) 2001-2018 Openbravo, S.L.U.
   *
   * Specifically, this derivative work is based upon the following Compiere
   * file and version.
@@ -272,7 +272,7 @@
        FROM fin_payment p
        WHERE p.c_bpartner_id = :new.C_BPartner_ID
        AND p.generated_credit <> 0
-       AND p.generated_credit-COALESCE(p.used_credit, 0) <> 0;
+       AND obequals(p.generated_credit, p.used_credit) = 'N';
       
 			 IF (v_currency_pl <> COALESCE(v_currency_credit, v_currency_pl)) THEN
 			   SELECT iso_code