|View Issue Details|
|Type||Category||Severity||Reproducibility||Date Submitted||Last Update|
|design defect||[Openbravo ERP] I. Performance||minor||always||2017-09-19 18:43||2017-09-19 18:56|
|Assigned To||Triage Finance|
|Priority||normal||Resolution||open||Fixed in Version|
|Status||new||Fix in branch||Fixed in SCM revision|
|OS Version||Database version||Ant version|
|Product Version||SCM revision|
|Review Assigned To|
|Regression introduced in release|
|Regression introduced by commit|
|Triggers an Emergency Pack||No|
0036898: Performance issues when using DAL
|Description||On 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 Files|| 0.diff [^] (14,677 bytes) 2017-09-19 18:52 [Show Content]
0.txt [^] (962 bytes) 2017-09-19 18:53 [Show Content]
|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|