Openbravo Issue Tracking System - Retail Modules
View Issue Details
0033615Retail ModulesWeb POSpublic2016-06-05 15:122016-08-25 12:46
shuehner 
mario_castello 
normalmajorhave not tried
closedfixed 
5
 
RR16Q3.1RR16Q3.1 
guilleaer
No
0033615: OrderLoader: Inefficient check for m_locator doing 2-3 queries for the same
OrderLoader is querying m_locator (for order.getWarehouse()) essentially up to 3 times

1.) just after 'if (createShipment)' to see if none are present and error out
2.) a few lines later in call to createShipment doing .count() to check if exactly one is present
3.) then just after that said count another .uniqueResult() to retrieve that 'exactly one'

All those can be done with a single sql.
Trace SQL done by OrderLoader.
Replace all 3 calls by single query.

Adding simple .setMaxResults(2) and .list() gives us all the info we need and the limit 2 avoids ever reading >2 rows into memory.

Note: Even while only wanting .count()==1 and reading single row we need to use a limit of 2 to distinguish the count=1 or count>1 case.

As we only care about count being exactly 1 (or not) we do not need to do proper count for any values >1 to the limit 2 does the trick nicely.

No tags attached.
blocks defect 0033139 closed mario_castello OrderLoader: Inefficient check for m_locator doing 2-3 queries for the same 
Issue History
2016-08-03 14:26marvintmTypedefect => backport
2016-08-03 14:26marvintmTarget Version => RR16Q3
2016-08-04 11:25marvintmTarget VersionRR16Q3 => RR16Q3.1
2016-08-17 10:38guilleaerAssigned ToRetail => mario_castello
2016-08-17 21:52hgbotCheckin
2016-08-17 21:52hgbotNote Added: 0089189
2016-08-17 21:52hgbotStatusscheduled => resolved
2016-08-17 21:52hgbotResolutionopen => fixed
2016-08-17 21:52hgbotFixed in SCM revision => http://code.openbravo.com/retail/backports/3.0RR16Q3.1/org.openbravo.retail.posterminal/rev/fdaba951742836c005c827cdb27d6e5575f592b4 [^]
2016-08-25 12:46guilleaerReview Assigned To => guilleaer
2016-08-25 12:46guilleaerStatusresolved => closed
2016-08-25 12:46guilleaerFixed in Version => RR16Q3.1

Notes
(0089189)
hgbot   
2016-08-17 21:52   
Repository: retail/backports/3.0RR16Q3.1/org.openbravo.retail.posterminal
Changeset: fdaba951742836c005c827cdb27d6e5575f592b4
Author: Mario Castello <mario.castello <at> peoplewalking.com>
Date: Wed Aug 03 14:28:43 2016 -0600
URL: http://code.openbravo.com/retail/backports/3.0RR16Q3.1/org.openbravo.retail.posterminal/rev/fdaba951742836c005c827cdb27d6e5575f592b4 [^]

Fixed issue 0033615: Replace the sames query for m_locator in orderloader class for only one query

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