Anonymous | Login
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
TypeCategorySeverityReproducibilityDate SubmittedLast Update
design defect[Openbravo ERP] I. Performanceminoralways2017-09-19 18:432017-09-19 18:56
Reportermarkmm82View Statuspublic 
Assigned ToTriage Finance 
PrioritynormalResolutionopenFixed in Version
StatusnewFix in branchFixed in SCM revision
ProjectionnoneETAnoneTarget Version
OSAnyDatabaseAnyJava version
OS VersionDatabase versionAnt version
Product VersionSCM revision 
Review Assigned To
Web browser
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo

0036898: Performance issues when using DAL

DescriptionOn many occasions when we perform a query with DAL, we do not do it quite well from a performance point of view. Here are some rules we should always follow:
• When we just want to know the number of records returned by the query, we usually do: query.list().size(). However it is better to do query.count(). If in addition to the number of records, we want to go through them, then it is better to store in a variable the result: list = query.list() and then look at its size: list.size().
• If, in addition to scrolling through the list, we want to know if we have at least one record, what we should do is: list.isEmpty(), instead of list.size ()> 0.
• It is important not to ever run the query.list() more than once, since that throws the same query twice. To do this, we execute the query only once and store it in a variable.
• When we only want to access the first record returned by the query, then we must use query.setMaxResults(1) in case the query returns more than one record, and we will return it using object = query.uniqueResult() instead of doing query.list().get(0).
• If you want to see if the query returns a record or not, just do the previous point and see if object ! = null.

These issues are found in many places along OB. For each of these cases code should be adapted to behave as explained above.
Steps To Reproduce-
Attached Filesdiff file icon 0.diff [^] (14,677 bytes) 2017-09-19 18:52 [Show Content]
txt file icon 0.txt [^] (962 bytes) 2017-09-19 18:53 [Show Content]

- Relationships Relation Graph ] Dependency Graph ]
related to defect 0033771 closedshuehner Openbravo ERP Accidental double query in SE_Invoice_BPartner.isAutomaticCombination 
related to defect 0033773 closedshuehner Openbravo ERP Accidental double queries in Initial Client Setup 
related to defect 0033774 closedshuehner Openbravo ERP Accidental double queries in Initial Org Setup 
related to feature request 0033767 closedplatform Openbravo ERP Add code to auto-detect 'accidental double query' on same OBQuery or OBCriteria object 
related to defect 0033703 closedshuehner Openbravo ERP Accidental double query in View generation 
related to defect 0033704 closedshuehner Openbravo ERP Accidental double query in 'selector dropdown' of new style selectors 
related to defect 0033705 closedshuehner Openbravo ERP Double query in PricelistVersionFilterExpression (product selector) 
related to defect 0033706 closedshuehner Openbravo ERP SelectorDataSourceFilter does accidental extra queries in 'Add Payment' flow of Sales Orders 
related to defect 0033707 closedshuehner Openbravo ERP Accidental triple query in OBMessageUtils.getI18NMessage 
depends on defect 0033709 closedshuehner Retail Modules Double query for posterminal in POSUtil.getLastDocumentNumber*ForPos 
related to defect 0036747 closedAtulOpenbravo Openbravo ERP Avoid query more than once in several classes 

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2017-09-19 18:43 markmm82 New Issue
2017-09-19 18:43 markmm82 Assigned To => Triage Finance
2017-09-19 18:43 markmm82 Modules => Core
2017-09-19 18:43 markmm82 Triggers an Emergency Pack => No
2017-09-19 18:47 markmm82 Relationship added related to 0033771
2017-09-19 18:47 markmm82 Relationship added related to 0033773
2017-09-19 18:47 markmm82 Relationship added related to 0033774
2017-09-19 18:48 markmm82 Relationship added related to 0033767
2017-09-19 18:48 markmm82 Relationship added related to 0033703
2017-09-19 18:49 markmm82 Relationship added related to 0033704
2017-09-19 18:49 markmm82 Relationship added related to 0033705
2017-09-19 18:49 markmm82 Relationship added related to 0033706
2017-09-19 18:50 markmm82 Relationship added related to 0033707
2017-09-19 18:50 markmm82 Relationship added depends on 0033709
2017-09-19 18:51 markmm82 Tag Attached: Performance
2017-09-19 18:52 markmm82 File Added: 0.diff
2017-09-19 18:53 markmm82 File Added: 0.txt
2017-09-20 13:09 aferraz Relationship added related to 0036747

Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker