details:   /erp/devel/pi/rev/b356fc9b31a7
changeset: 10588:b356fc9b31a7
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Fri Feb 11 17:36:54 2011 +0100
summary:   Fixed 15731. Fix performance issue in locator selector.
Remove a column which has an expensive function call from the select, as it was
just not used.

details:   /erp/devel/pi/rev/83f81d4ac280
changeset: 10589:83f81d4ac280
user:      Stefan Hühner <stefan.huehner <at> openbravo.com>
date:      Fri Feb 11 17:41:28 2011 +0100
summary:   Issue 15731. Do some cleanup.
- Locator.java:
  - remove some unused code/comments
  - convert use of printStacktrace to log4j
- Project.java
  - remove some unused  code/comments
  - convert use of printStacktrace to log4j
- Project_java.xsql
  - remove to resultset columns which are not used

diffstat:

 src/org/openbravo/erpCommon/info/Locator.java      |  34 +++++++--------------
 src/org/openbravo/erpCommon/info/Locator_data.xsql |   5 +-
 src/org/openbravo/erpCommon/info/Project.java      |  20 +++---------
 src/org/openbravo/erpCommon/info/Project_data.xsql |   3 +-
 4 files changed, 19 insertions(+), 43 deletions(-)

diffs (202 lines):

diff -r 3745c4f627cc -r 83f81d4ac280 
src/org/openbravo/erpCommon/info/Locator.java
--- a/src/org/openbravo/erpCommon/info/Locator.java     Fri Feb 11 15:25:04 
2011 +0100
+++ b/src/org/openbravo/erpCommon/info/Locator.java     Fri Feb 11 17:41:28 
2011 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2010 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2011 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -203,11 +203,6 @@
   private SQLReturnObject[] getHeaders(VariablesSecureApp vars) {
     SQLReturnObject[] data = null;
     Vector<SQLReturnObject> vAux = new Vector<SQLReturnObject>();
-    String[] colNames = { "name", "value", "aisle", "bin", "nivel", 
"priorityno", "isdefault",
-        "rowkey" };
-    // String[] gridNames = {"Key", "Name","Disp. Credit","Credit used",
-    // "Contact", "Phone no.", "Zip", "City", "Income", "c_bpartner_id",
-    // "c_bpartner_contact_id", "c_bpartner_location_id", "rowkey"};
     String[] colWidths = { "270", "150", "68", "68", "68", "90", "70", "0" };
     for (int i = 0; i < colNames.length; i++) {
       SQLReturnObject dataAux = new SQLReturnObject();
@@ -258,11 +253,8 @@
         int oldOffset = offset;
         offset = (page * TableSQLData.maxRowsPerGridPage) + offset;
         log4j.debug("relativeOffset: " + oldOffset + " absoluteOffset: " + 
offset);
-        if (strNewFilter.equals("1") || strNewFilter.equals("")) { // New
-          // filter
-          // or
-          // first
-          // load
+        if (strNewFilter.equals("1") || strNewFilter.equals("")) {
+          // New filter or first load
           String rownum = "0", oraLimit1 = null, oraLimit2 = null, pgLimit = 
null;
           if (this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
             oraLimit1 = String.valueOf(offset + 
TableSQLData.maxRowsPerGridPage);
@@ -274,7 +266,6 @@
           strNumRows = LocatorData.countRows(this, rownum, 
Utility.getContext(this, vars,
               "#User_Client", "Locator"), Utility.getSelectorOrgs(this, vars, 
strOrg), strName,
               strWarehousename, strAisle, strBin, strLevel, pgLimit, 
oraLimit1, oraLimit2);
-          // strNumRows = String.valueOf(data.length);
           vars.setSessionValue("Locator.numrows", strNumRows);
         } else {
           strNumRows = vars.getSessionValue("Locator.numrows");
@@ -283,18 +274,17 @@
         // Filtering result
         if (this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
           String oraLimit = (offset + 1) + " AND " + String.valueOf(offset + 
pageSize);
-          data = LocatorData.select(this, "ROWNUM", vars.getLanguage(), 
Utility.getContext(this,
-              vars, "#User_Client", "Locator"), Utility.getSelectorOrgs(this, 
vars, strOrg),
-              strName, strWarehousename, strAisle, strBin, strLevel, 
strOrderBy, oraLimit, "");
+          data = LocatorData.select(this, "ROWNUM", Utility.getContext(this, 
vars, "#User_Client",
+              "Locator"), Utility.getSelectorOrgs(this, vars, strOrg), 
strName, strWarehousename,
+              strAisle, strBin, strLevel, strOrderBy, oraLimit, "");
         } else {
           String pgLimit = pageSize + " OFFSET " + offset;
-          data = LocatorData.select(this, "1", vars.getLanguage(), 
Utility.getContext(this, vars,
-              "#User_Client", "Locator"), Utility.getSelectorOrgs(this, vars, 
strOrg), strName,
-              strWarehousename, strAisle, strBin, strLevel, strOrderBy, "", 
pgLimit);
+          data = LocatorData.select(this, "1", Utility.getContext(this, vars, 
"#User_Client",
+              "Locator"), Utility.getSelectorOrgs(this, vars, strOrg), 
strName, strWarehousename,
+              strAisle, strBin, strLevel, strOrderBy, "", pgLimit);
         }
       } catch (ServletException e) {
-        log4j.error("Error in print page data: " + e);
-        e.printStackTrace();
+        log4j.error("Error in print page data: ", e);
         OBError myError = Utility.translateError(this, vars, 
vars.getLanguage(), e.getMessage());
         if (!myError.isConnectionAvailable()) {
           bdErrorAjax(response, "Error", "Connection Error", "No database 
connection");
@@ -308,15 +298,13 @@
             description = myError.getMessage();
         }
       } catch (Exception e) {
-        if (log4j.isDebugEnabled())
-          log4j.debug("Error obtaining rows data");
+        log4j.error("Error obtaining rows data", e);
         type = "Error";
         title = "Error";
         if (e.getMessage().startsWith("<![CDATA["))
           description = "<![CDATA[" + e.getMessage() + "]]>";
         else
           description = e.getMessage();
-        e.printStackTrace();
       }
     }
 
diff -r 3745c4f627cc -r 83f81d4ac280 
src/org/openbravo/erpCommon/info/Locator_data.xsql
--- a/src/org/openbravo/erpCommon/info/Locator_data.xsql        Fri Feb 11 
15:25:04 2011 +0100
+++ b/src/org/openbravo/erpCommon/info/Locator_data.xsql        Fri Feb 11 
17:41:28 2011 +0100
@@ -12,7 +12,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2009 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2011 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -29,7 +29,7 @@
       <Sql>
       <![CDATA[
       SELECT * FROM ( SELECT '0' AS RN1, A.* FROM (                            
           
-        SELECT m.M_LOCATOR_ID, mw.NAME, m.VALUE, 
REPLACE(AD_COLUMN_IDENTIFIER(TO_CHAR('M_LOCATOR'), TO_CHAR(m.M_LOCATOR_ID), 
TO_CHAR(?)), '''', chr(92)||'''') AS VALUE_HIDDEN, m.PRIORITYNO, 
+        SELECT m.M_LOCATOR_ID, mw.NAME, m.VALUE, m.PRIORITYNO, 
         m.ISDEFAULT, m.X AS aisle, m.Y AS bin, m.Z AS nivel,
         m.M_LOCATOR_ID || '@_##_@' || m.value  AS rowKey
         FROM M_LOCATOR m, M_WAREHOUSE mw,Ad_Org ao
@@ -47,7 +47,6 @@
         </Sql>
         <Field name="position" value="count"/>
         <Parameter name="rownum" type="replace" optional="true" after="FROM ( 
SELECT " text="'0'" />
-        <Parameter name="adLanguage"/>
         <Parameter name="adUserClient" type="replace" optional="true" 
after="mw.AD_Client_ID IN (" text="'1'"/>
         <Parameter name="adUserOrg" type="replace" optional="true" 
after="mw.AD_Org_ID IN (" text="'1'"/>
         <Parameter name="key" ignoreValue="%" optional="true" after="AND 
m.ISACTIVE = 'Y'"><![CDATA[ AND UPPER(m.VALUE) LIKE UPPER(?) ]]></Parameter>
diff -r 3745c4f627cc -r 83f81d4ac280 
src/org/openbravo/erpCommon/info/Project.java
--- a/src/org/openbravo/erpCommon/info/Project.java     Fri Feb 11 15:25:04 
2011 +0100
+++ b/src/org/openbravo/erpCommon/info/Project.java     Fri Feb 11 17:41:28 
2011 +0100
@@ -11,7 +11,7 @@
  * under the License. 
  * The Original Code is Openbravo ERP. 
  * The Initial Developer of the Original Code is Openbravo SLU 
- * All portions are Copyright (C) 2001-2009 Openbravo SLU 
+ * All portions are Copyright (C) 2001-2011 Openbravo SLU 
  * All Rights Reserved. 
  * Contributor(s):  ______________________________________.
  ************************************************************************
@@ -213,9 +213,6 @@
   private SQLReturnObject[] getHeaders(VariablesSecureApp vars) {
     SQLReturnObject[] data = null;
     Vector<SQLReturnObject> vAux = new Vector<SQLReturnObject>();
-    // String[] gridNames = {"Key", "Name","Disp. Credit","Credit used",
-    // "Contact", "Phone no.", "Zip", "City", "Income", "c_bpartner_id",
-    // "c_bpartner_contact_id", "c_bpartner_location_id", "rowkey"};
     String[] colWidths = { "98", "300", "250", "120", "0" };
     for (int i = 0; i < colNames.length; i++) {
       SQLReturnObject dataAux = new SQLReturnObject();
@@ -266,11 +263,8 @@
         int oldOffset = offset;
         offset = (page * TableSQLData.maxRowsPerGridPage) + offset;
         log4j.debug("relativeOffset: " + oldOffset + " absoluteOffset: " + 
offset);
-        if (strNewFilter.equals("1") || strNewFilter.equals("")) { // New
-          // filter
-          // or
-          // first
-          // load
+        if (strNewFilter.equals("1") || strNewFilter.equals("")) {
+          // New filter or first load
           String rownum = "0", oraLimit1 = null, oraLimit2 = null, pgLimit = 
null;
           if (this.myPool.getRDBMS().equalsIgnoreCase("ORACLE")) {
             oraLimit1 = String.valueOf(offset + 
TableSQLData.maxRowsPerGridPage);
@@ -282,7 +276,6 @@
           strNumRows = ProjectData.countRows(this, rownum, vars.getLanguage(), 
Utility.getContext(
               this, vars, "#User_Client", "Project"), 
Utility.getSelectorOrgs(this, vars, strOrg),
               strKey, strName, strBpartners, pgLimit, oraLimit1, oraLimit2);
-          // strNumRows = String.valueOf(data.length);
           vars.setSessionValue("ProjectData.numrows", strNumRows);
         } else {
           strNumRows = vars.getSessionValue("ProjectData.numrows");
@@ -301,8 +294,7 @@
               strName, strBpartners, strOrderBy, "", pgLimit);
         }
       } catch (ServletException e) {
-        log4j.error("Error in print page data: " + e);
-        e.printStackTrace();
+        log4j.error("Error in print page data: ", e);
         OBError myError = Utility.translateError(this, vars, 
vars.getLanguage(), e.getMessage());
         if (!myError.isConnectionAvailable()) {
           bdErrorAjax(response, "Error", "Connection Error", "No database 
connection");
@@ -316,15 +308,13 @@
             description = myError.getMessage();
         }
       } catch (Exception e) {
-        if (log4j.isDebugEnabled())
-          log4j.debug("Error obtaining rows data");
+        log4j.error("Error obtaining rows data", e);
         type = "Error";
         title = "Error";
         if (e.getMessage().startsWith("<![CDATA["))
           description = "<![CDATA[" + e.getMessage() + "]]>";
         else
           description = e.getMessage();
-        e.printStackTrace();
       }
     }
 
diff -r 3745c4f627cc -r 83f81d4ac280 
src/org/openbravo/erpCommon/info/Project_data.xsql
--- a/src/org/openbravo/erpCommon/info/Project_data.xsql        Fri Feb 11 
15:25:04 2011 +0100
+++ b/src/org/openbravo/erpCommon/info/Project_data.xsql        Fri Feb 11 
17:41:28 2011 +0100
@@ -28,8 +28,7 @@
       <SqlMethodComment></SqlMethodComment>
       <Sql> <![CDATA[
       SELECT * FROM ( SELECT '0' AS RN1, A.* FROM (  
-        SELECT P.C_PROJECT_ID, P.VALUE, REPLACE(P.VALUE, '''', CHR(92) || 
'''') AS VALUE_HIDDEN, P.NAME, P.C_BPARTNER_ID, 
-        REPLACE(P.NAME, '''', CHR(92) || CHR(92) || '''') AS NAME_HIDDEN, 
+        SELECT P.C_PROJECT_ID, P.VALUE, P.NAME, P.C_BPARTNER_ID, 
         B.NAME AS BPARTNER, L.NAME AS PROJECTSTATUS,
         p.c_Project_Id || '@_##_@' || p.value || ' - ' || p.name as rowkey
         FROM C_PROJECT P, C_BPARTNER B, AD_REF_LIST_V L 

------------------------------------------------------------------------------
The ultimate all-in-one performance toolkit: Intel(R) Parallel Studio XE:
Pinpoint memory and threading errors before they happen.
Find and fix more than 250 security defects in the development cycle.
Locate bottlenecks in serial and parallel code that limit performance.
http://p.sf.net/sfu/intel-dev2devfeb
_______________________________________________
Openbravo-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openbravo-commits

Reply via email to