details: https://code.openbravo.com/erp/devel/pi/rev/def566d2011a changeset: 25728:def566d2011a user: Unai Martirena <unai.martirena <at> openbravo.com> date: Mon Jan 19 19:04:16 2015 +0100 summary: Fixed bug 28061: Performance problems on the payment monitor process.
Changed FIN_PaymentMonitorProcess class to use a ScrollableResults instead of a list. details: https://code.openbravo.com/erp/devel/pi/rev/49de63d764cc changeset: 25729:49de63d764cc user: Fernando Soto <fernando.soto <at> peoplewalking.com> date: Tue Jan 13 11:52:49 2015 -0500 summary: Fixed bug 28031: Performance problems on the payment monitor process. Created new index c_invoice_paid in c_invoice table using ispaid column. diffstat: modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentMonitorProcess.java | 28 +++++---- src-db/database/model/tables/C_INVOICE.xml | 3 + 2 files changed, 18 insertions(+), 13 deletions(-) diffs (85 lines): diff -r 62ba0387a47d -r 49de63d764cc modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentMonitorProcess.java --- a/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentMonitorProcess.java Wed Jan 07 18:55:41 2015 -0500 +++ b/modules/org.openbravo.advpaymentmngt/src/org/openbravo/advpaymentmngt/process/FIN_PaymentMonitorProcess.java Tue Jan 13 11:52:49 2015 -0500 @@ -11,7 +11,7 @@ * under the License. * The Original Code is Openbravo ERP. * The Initial Developer of the Original Code is Openbravo SLU - * All portions are Copyright (C) 2010-2012 Openbravo SLU + * All portions are Copyright (C) 2010-2015 Openbravo SLU * All Rights Reserved. * Contributor(s): ______________________________________. ************************************************************************* @@ -24,10 +24,10 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.HashMap; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import org.hibernate.ScrollMode; +import org.hibernate.ScrollableResults; import org.hibernate.criterion.Projections; import org.hibernate.criterion.Restrictions; import org.openbravo.advpaymentmngt.utility.FIN_Utility; @@ -81,6 +81,7 @@ return; } + ScrollableResults invoiceScroller = null; try { int counter = 0; final Module migration = OBDal.getInstance().get(Module.class, @@ -109,27 +110,28 @@ obc.setFilterOnReadableClients(false); obc.setFilterOnReadableOrganization(false); } - final Set<String> invoiceIds = new HashSet<String>(); - for (Invoice invoice : obc.list()) { - invoiceIds.add(invoice.getId()); - } - for (String invoiceId : invoiceIds) { - Invoice invoice = OBDal.getInstance().get(Invoice.class, invoiceId); + invoiceScroller = obc.scroll(ScrollMode.FORWARD_ONLY); + while (invoiceScroller.next()) { + final Invoice invoice = (Invoice) invoiceScroller.get()[0]; updateInvoice(invoice); counter++; - OBDal.getInstance().getSession().flush(); - OBDal.getInstance().getSession().clear(); - if (counter % 50 == 0) { + if (counter % 100 == 0) { + OBDal.getInstance().getSession().flush(); + OBDal.getInstance().getSession().clear(); logger.log("Invoices updated: " + counter + "\n"); } } - if (counter % 50 != 0) + if (counter % 100 != 0) logger.log("Invoices updated: " + counter + "\n"); } catch (Exception e) { // catch any possible exception and throw it as a Quartz // JobExecutionException throw new JobExecutionException(e.getMessage(), e); + } finally { + if (invoiceScroller != null) { + invoiceScroller.close(); + } } } diff -r 62ba0387a47d -r 49de63d764cc src-db/database/model/tables/C_INVOICE.xml --- a/src-db/database/model/tables/C_INVOICE.xml Wed Jan 07 18:55:41 2015 -0500 +++ b/src-db/database/model/tables/C_INVOICE.xml Tue Jan 13 11:52:49 2015 -0500 @@ -364,6 +364,9 @@ <index name="C_INVOICE_ORDER" unique="false"> <index-column name="C_ORDER_ID"/> </index> + <index name="C_INVOICE_PAID" unique="false"> + <index-column name="ISPAID"/> + </index> <index name="C_INVOICE_UPDATED" unique="false"> <index-column name="UPDATED"/> </index> ------------------------------------------------------------------------------ New Year. New Location. New Benefits. New Data Center in Ashburn, VA. GigeNET is offering a free month of service with a new server in Ashburn. Choose from 2 high performing configs, both with 100TB of bandwidth. Higher redundancy.Lower latency.Increased capacity.Completely compliant. http://p.sf.net/sfu/gigenet _______________________________________________ Openbravo-commits mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openbravo-commits
