Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0033186Openbravo ERPA. Platformpublic2016-06-07 20:372016-06-10 12:00
shuehner 
shuehner 
normalminorhave not tried
closedfixed 
5
 
3.0PR16Q3 
alostale
Core
No
0033186: OBContext.setReadableOrganizations loads tons of Organization objects into DAL session
Triggered via.
OrderLoader -> initializeVariables -> Preferences.getPreferenceValue -> OBQuery.addOrgClientActiveFilter -> obContext.getReadableOrganizations() -> setReadableOrganizations.

Issue is essentially
getOrganizationList
getOrganizations

both query database and return list of DAL Organization objects which are thus loaded into current DAL session and kept until next .clear()

However reviewing example users of those lists
setReadableOrganizations

shows that those DAL objects are not really needed as full objects but simple String of id is enough.

Prototyping to replace the 2 functions to return 'o.id' in HQL query shows directly a drop of number of Organizations in DAL session from >=300 down to 1

Note: Patch is proof of concept only but shows the improvement in number of dal objects in session in the single tested flow. Patch has both proof of concept + debugging code to debug-print number of objects in session
-
Performance
related to defect 0033187 closed shuehner OrganizationStructureProvider loads many ADTreeNode DAL objects into memory which could be avoided. 
diff 33186.diff (4,699) 2016-06-07 20:37
https://issues.openbravo.com/file_download.php?file_id=9502&type=bug
diff 33186_v2.diff (4,465) 2016-06-08 23:10
https://issues.openbravo.com/file_download.php?file_id=9509&type=bug
Issue History
2016-06-07 20:37shuehnerNew Issue
2016-06-07 20:37shuehnerAssigned To => platform
2016-06-07 20:37shuehnerModules => Core
2016-06-07 20:37shuehnerTriggers an Emergency Pack => No
2016-06-07 20:37shuehnerTag Attached: Performance
2016-06-07 20:37shuehnerFile Added: 33186.diff
2016-06-07 21:14shuehnerRelationship addedrelated to 0033187
2016-06-08 23:10shuehnerFile Added: 33186_v2.diff
2016-06-08 23:10shuehnerNote Added: 0087102
2016-06-10 11:46alostaleAssigned Toplatform => shuehner
2016-06-10 11:46alostaleReview Assigned To => alostale
2016-06-10 11:55hgbotCheckin
2016-06-10 11:55hgbotNote Added: 0087148
2016-06-10 11:55hgbotStatusnew => resolved
2016-06-10 11:55hgbotResolutionopen => fixed
2016-06-10 11:55hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/1f8eba41e1f1f21e38311d4ac934f2890e8e0ee5 [^]
2016-06-10 12:00alostaleNote Added: 0087150
2016-06-10 12:00alostaleStatusresolved => closed
2016-06-10 12:00alostaleFixed in Version => 3.0PR16Q3

Notes
(0087102)
shuehner   
2016-06-08 23:10   
Attached cleanup version of the prototype patch without lots of testing + debugging code
(0087148)
hgbot   
2016-06-10 11:55   
Repository: erp/devel/pi
Changeset: 1f8eba41e1f1f21e38311d4ac934f2890e8e0ee5
Author: Stefan Hühner <stefan.huehner <at> openbravo.com>
Date: Fri Jun 10 11:53:53 2016 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/1f8eba41e1f1f21e38311d4ac934f2890e8e0ee5 [^]

fixed 33186: OBContext.setReadableOrganizations loads Org objects in session

  OBContext.setReadableOrganizations, invoked on session creation, loaded full
  DAL Organization objects in session. This caused slowness while loading and
  in subsequent DAL flushes.

  Now instead of loading full DAL objects, only ids are fetched from DB, in this
  manner initialization is faster and flushes don't get affected.

---
M src/org/openbravo/dal/core/OBContext.java
---
(0087150)
alostale   
2016-06-10 12:00   
code reviewed

tested:
- now when those organization objects are not seen anymore when flushing in order loader