Openbravo Issue Tracking System - Retail Modules
View Issue Details
0033137Retail ModulesWeb POSpublic2016-06-05 14:142016-06-15 19:12
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
 
marvintm
No
0033137: Useless m_product read from services product even if services are not used
The addition of services project with createLinesForServiceProduct and the HashMap orderlineServiceList added a m_product read to OrderLoader which is not required if services are not used.

That extra overhead should be at least avoided if services are not used.

Relevant code is in createOrderLines:
      if ("S".equals(orderline.getProduct().getProductType())) {
        // related can be null
        if (jsonOrderLine.has("relatedLines")) {
          orderLineServiceList.put(orderline.getId(), jsonOrderLine.getJSONArray("relatedLines"));

The conditions can be swapped around to avoid the getProduct() call if there is no relatedLines in the json.
Trace all SQL of orderloader.
Performance
related to defect 0033178 closed Sandrahuguet Service project related code in OrderLoader re-reads just created orderline 
diff 33137_part1.diff (4,710) 2016-06-05 14:20
https://issues.openbravo.com/file_download.php?file_id=9484&type=bug
diff 33137_part2.diff (802) 2016-06-05 14:20
https://issues.openbravo.com/file_download.php?file_id=9485&type=bug
Issue History
2016-06-05 14:14shuehnerNew Issue
2016-06-05 14:14shuehnerAssigned To => Retail
2016-06-05 14:14shuehnerTriggers an Emergency Pack => No
2016-06-05 14:14shuehnerTag Attached: Performance
2016-06-05 14:20shuehnerNote Added: 0087002
2016-06-05 14:20shuehnerFile Added: 33137_part1.diff
2016-06-05 14:20shuehnerFile Added: 33137_part2.diff
2016-06-07 18:09shuehnerRelationship addedrelated to 0033178
2016-06-09 15:48hgbotCheckin
2016-06-09 15:48hgbotNote Added: 0087130
2016-06-09 15:48hgbotCheckin
2016-06-09 15:48hgbotNote Added: 0087131
2016-06-09 15:48hgbotStatusnew => resolved
2016-06-09 15:48hgbotResolutionopen => fixed
2016-06-09 15:48hgbotFixed in SCM revision => http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/ff679a9729794badd242c68064c80efc8c4e1457 [^]
2016-06-09 15:57shuehnerAssigned ToRetail => shuehner
2016-06-09 15:57shuehnerReview Assigned To => marvintm
2016-06-15 19:12marvintmStatusresolved => closed

Notes
(0087002)
shuehner   
2016-06-05 14:20   
Patch in 2 parts:
a.) Review createLinesForServiceProduct function which only does any real work if the 'value' part of the HashMap is not null.
So the else part inside createOrderLines which insert into the HashMap with value=null is useless.
33137_part1.diff cleans up that part to avoid some overhead and simplify the code.

b.) Now with the part inside createOrderLines simplified the 2 if conditions can be swapped around which does not trigger getProduct() sql read unless there is really a relatedLines item present in the json.

So the read overhead is removed unless services/relatedLines are really used.
(0087130)
hgbot   
2016-06-09 15:48   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: 70c2aca3faa72a1a4535e3ca46e94c481dd9bd2c
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Tue Jun 07 17:19:06 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/70c2aca3faa72a1a4535e3ca46e94c481dd9bd2c [^]

Issue 33137. Simplify code related to createLinesForServiceProduct.

The only reader of the HashMap orderLineServiceList only does any processing
if the value part of the map is not null.
So avoid inserting into the HashMap any entries which have value null as those
are not useful (and remove the != null check also)

---
M src/org/openbravo/retail/posterminal/OrderLoader.java
---
(0087131)
hgbot   
2016-06-09 15:48   
Repository: erp/pmods/org.openbravo.retail.posterminal
Changeset: ff679a9729794badd242c68064c80efc8c4e1457
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Tue Jun 07 17:20:39 2016 +0200
URL: http://code.openbravo.com/erp/pmods/org.openbravo.retail.posterminal/rev/ff679a9729794badd242c68064c80efc8c4e1457 [^]

Fixed 33137. Avoid m_product read if not service lines are used.

Swap check condition for m_product.getType() == S and if the json
has a relatedLines part.
By checking json first we avoid the m_product read in the normal case.

---
M src/org/openbravo/retail/posterminal/OrderLoader.java
---