Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0042385
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Retail Modules] Web POSmajorhave not tried2019-11-25 11:022019-12-09 14:59
ReporterALopeteguiView Statuspublic 
Assigned Torqueralta 
PriorityimmediateResolutionfixedFixed in VersionRR20Q1
StatusclosedFix in branchFixed in SCM revision344327c0b6d7
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned Tomarvintm
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0042385: Performance improvement in PaidReceipts query

DescriptionPerformance issue in PaidReceipts query, when loading payment method for the financial account related to the payments of the order.

The problem of the query is that first finds all the payment methods in all financial account of all the terminals, and then have a sub-select for payments of the order to filter it.

In Big customer the query takes 200ms ans is executed 30.000 times by day
Steps To ReproduceFind and load a Tickets in a database with high volumes
Proposed SolutionThe solution is to change the order of the query, first find payments of the order, and then only find those payment methods.

With this improvement the query takes 10 times less time, and reads 3 times less from disk or memory.

Attached, diff of solution.
TagsNo tags attached.
Attached Filesdiff file icon improvePerformancePaidReceipts_pi.diff [^] (2,955 bytes) 2019-11-25 11:02 [Show Content]
png file icon 2019112610:01:56.png [^] (65,116 bytes) 2019-11-26 10:02

- Relationships Relation Graph ] Dependency Graph ]
depends on defect 0040876 closedrqueralta Multiple payment methods are shown when their have the same financial account 
related to defect 0037653 closedranjith_qualiantech_com Performance problem in PaidReceipts 

-  Notes
(0115795)
guilleaer (manager)
2019-11-25 12:27
edited on: 2019-11-25 12:27

Patch reviewed by me. Now passing try

(0115817)
guilleaer (manager)
2019-11-26 10:01

After pass try one test failed

retail.pack.selenium.tests.cashmanagement.I40876_VerifyOnlyOnePayMethodShownIfSharesFinAcct [attached image with the problem]


It seems that the fix done for issue 40876 needs to be reapplied (in a correct way) to maintain the performance improvement but also to cover this case.
(0115883)
ALopetegui (reporter)
2019-11-27 13:41
edited on: 2019-11-27 13:41

There are another two places where that hql code is repeated, So it's also necessary also to replace them:

https://code.openbravo.com/erp/pmods/org.openbravo.retail.digitalcoupons/file/tip/src/org/openbravo/retail/digitalcoupons/process/DigitalCouponsPaidReceiptsPaymentsTypeHook.java#l35 [^]

https://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/file/tip/src/org/openbravo/retail/posterminal/Invoices.java#l196Invoices.java [^]
(this is the same but for invoiceid instead of orderid)

(0115887)
ALopetegui (reporter)
2019-11-27 13:54

The are two different results depending if the order has payments or not:

If yes:
Old query: 1ms -> https://explain.depesz.com/s/7S4Z [^]
New query: 22ms -> https://explain.depesz.com/s/i5zt [^]

If not:
Old Query: 200ms -> https://explain.depesz.com/s/Eg3oL [^]
New query: 19ms -> https://explain.depesz.com/s/P0s [^]

That happens because if there is no payments in the old query the heavy part is not executed, but if yes it's very slow.

However if we add a new index:
New query takes only 1ms in both cases -> https://explain.depesz.com/s/QBjS [^]

Proposed index:
create index obpos_app_fin_account on OBPOS_APP_PAYMENT (fin_financial_account_id);
(0116129)
hgbot (developer)
2019-12-06 20:34

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 344327c0b6d79a1d1ff3fd60879bc377d104936a
Author: Guillermo Alvarez de Eulate <guillermo.alvarez <at> openbravo.com>
Date: Wed Dec 04 15:23:59 2019 -0500
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/344327c0b6d79a1d1ff3fd60879bc377d104936a [^]

Fixed issue 42385: Performance improvement in PaidReceipts query

 Improve performance in paid Receipt

---
M src/org/openbravo/retail/posterminal/PaidReceipts.java
---
(0116130)
hgbot (developer)
2019-12-06 20:34

Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 386b15cdffb4e30cb73c0182275eff8cabe25236
Author: Rafael Queralta <rafaelcuba81 <at> gmail.com>
Date: Thu Dec 05 16:43:31 2019 -0500
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/386b15cdffb4e30cb73c0182275eff8cabe25236 [^]

Related to issue 42385: Performance improvement in PaidReceipts query

- Readapted issue 40876 according to the solution of issue 42385 and added a new
index to improve the query

---
M src-db/database/model/tables/OBPOS_APP_PAYMENT.xml
M src/org/openbravo/retail/posterminal/Invoices.java
M src/org/openbravo/retail/posterminal/PaidReceipts.java
---
(0116150)
hgbot (developer)
2019-12-09 12:39

Repository: erp/pmods/org.openbravo.retail.digitalcoupons
Changeset: 147fe13c2ce22345182ee031450add2e5bbd83fa
Author: Rafael Queralta <rafaelcuba81 <at> gmail.com>
Date: Mon Dec 09 06:34:12 2019 -0500
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.digitalcoupons/rev/147fe13c2ce22345182ee031450add2e5bbd83fa [^]

Related to issue 42385: Performance improvement in PaidReceipts query

- Replaced the query of this module by the same query that was improved in
posterminal module

---
M src/org/openbravo/retail/digitalcoupons/process/DigitalCouponsPaidReceiptsPaymentsTypeHook.java
---

- Issue History
Date Modified Username Field Change
2019-11-25 11:02 ALopetegui New Issue
2019-11-25 11:02 ALopetegui Assigned To => Retail
2019-11-25 11:02 ALopetegui File Added: improvePerformancePaidReceipts_pi.diff
2019-11-25 11:02 ALopetegui Triggers an Emergency Pack => No
2019-11-25 12:27 guilleaer Note Added: 0115795
2019-11-25 12:27 guilleaer Note Edited: 0115795 View Revisions
2019-11-26 10:01 guilleaer Note Added: 0115817
2019-11-26 10:01 guilleaer File Added: 2019112609:52:57.png
2019-11-26 10:01 guilleaer File Deleted: 2019112609:52:57.png
2019-11-26 10:02 guilleaer File Added: 2019112610:01:56.png
2019-11-26 10:02 guilleaer Relationship added depends on 0040876
2019-11-26 10:02 guilleaer Assigned To Retail => rqueralta
2019-11-27 13:41 ALopetegui Note Added: 0115883
2019-11-27 13:41 ALopetegui Note Edited: 0115883 View Revisions
2019-11-27 13:54 ALopetegui Note Added: 0115887
2019-12-06 20:34 hgbot Checkin
2019-12-06 20:34 hgbot Note Added: 0116129
2019-12-06 20:34 hgbot Status new => resolved
2019-12-06 20:34 hgbot Resolution open => fixed
2019-12-06 20:34 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/344327c0b6d79a1d1ff3fd60879bc377d104936a [^]
2019-12-06 20:34 hgbot Checkin
2019-12-06 20:34 hgbot Note Added: 0116130
2019-12-07 08:11 ranjith_qualiantech_com Relationship added related to 0037653
2019-12-09 12:39 hgbot Checkin
2019-12-09 12:39 hgbot Note Added: 0116150
2019-12-09 14:59 marvintm Review Assigned To => marvintm
2019-12-09 14:59 marvintm Status resolved => closed
2019-12-09 14:59 marvintm Fixed in Version => RR20Q1


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker