Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0028968Openbravo ERPA. Platformpublic2015-02-17 16:572015-03-13 09:34
egoitz 
inigosanchez 
urgentmajoralways
closedfixed 
5
 
3.0PR15Q33.0PR15Q2 
alostale
Core
No
0028968: When installing a module the rebuild takes long to start when clicking on the rebuild button
When clicking on the rebuild button of the module management window, a poup is opened with 2 options. Rebuild and cancel.

When the ad_session table has more than a million of rows for many different users, after click the rebuild button it takes more than a minute to start the rebuild.

That could cause performance problems if you click on the button more than once if you think that you have not click properly the button.

-ON an environment with more than 1.000.000 rows on the ad_session table for different users install a module.
-Then click on rebuild button and on the popup click on the rebuild button again.
*It takes long to start the rebuild process

Attached a proposal solution.
The problem is that before rebuilding all the session for users different that your current users are set as session_active='N'.
It done for all the sessions , also the ones that are already with value 'N'
Performance
diff rebuild.diff (780) 2015-02-17 16:57
https://issues.openbravo.com/file_download.php?file_id=7799&type=bug
Issue History
2015-02-17 16:57egoitzNew Issue
2015-02-17 16:57egoitzAssigned To => AugustoMauch
2015-02-17 16:57egoitzFile Added: rebuild.diff
2015-02-17 16:57egoitzModules => Core
2015-02-17 16:57egoitzResolution time => 1426460400
2015-02-17 16:57egoitzTriggers an Emergency Pack => No
2015-02-17 16:58egoitzTag Attached: Performance
2015-02-23 08:48alostaleTarget Version3.0PR14Q3.6 => 3.0PR15Q2
2015-02-23 08:48alostaleStatusnew => acknowledged
2015-02-23 13:30jonalegriaesarteTarget Version3.0PR15Q2 => 3.0PR15Q3
2015-03-05 17:49alostaleStatusacknowledged => scheduled
2015-03-05 17:49alostaleAssigned ToAugustoMauch => inigosanchez
2015-03-11 10:43inigosanchezReview Assigned To => alostale
2015-03-11 10:43inigosanchezResolutionopen => fixed
2015-03-11 10:44hgbotCheckin
2015-03-11 10:44hgbotNote Added: 0075443
2015-03-11 10:44hgbotStatusscheduled => resolved
2015-03-11 10:44hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/3610bd347abc64f737a046903ecf5083c13af938 [^]
2015-03-12 17:10hudsonbotCheckin
2015-03-12 17:10hudsonbotNote Added: 0075497
2015-03-13 09:34alostaleNote Added: 0075519
2015-03-13 09:34alostaleStatusresolved => closed
2015-03-13 09:34alostaleFixed in Version => 3.0PR15Q2

Notes
(0075443)
hgbot   
2015-03-11 10:44   
Repository: erp/devel/pi
Changeset: 3610bd347abc64f737a046903ecf5083c13af938
Author: Inigo Sanchez <inigo.sanchez <at> openbravo.com>
Date: Wed Mar 11 10:42:05 2015 +0100
URL: http://code.openbravo.com/erp/devel/pi/rev/3610bd347abc64f737a046903ecf5083c13af938 [^]

Fixed issue 28968: When installing a module the rebuild takes long to start.

The problem was that when installing a module the rebuild takes long to start.
This happened on environments with a lot of rows (Tested with 260.000 rows) on
the ad_session table.The result was this:

explain UPDATE AD_SESSION SET SESSION_ACTIVE='N' WHERE CREATEDBY<>'100'
Update on ad_session (cost=0.00..21546.15 rows=266303 width=147)

  -> Seq Scan on ad_session (cost=0.00..21546.15 rows=266303 width=147)
        Filter: ((createdby)::text <> '100'::text)
    Approx time execution: 30000 ms

The new SQL Query to update is this:

explain UPDATE AD_SESSION SET SESSION_ACTIVE='N' WHERE CREATEDBY<>'100' and SESSION_ACTIVE='Y'
Update on ad_session (cost=0.42..4.44 rows=1 width=147)

  -> Index Scan using ad_session_active_idx on ad_session (cost=0.42..4.44 rows=1 width=147)
        Index Cond: (session_active = 'Y'::bpchar)
        Filter: ((createdby)::text <> '100'::text)
    Approx time execution: 30 ms

Adding the new condition "SESSION_ACTIVE = 'Y'" has been achieved to improve the performance.

---
M src/org/openbravo/erpCommon/ad_process/ApplyModules.java
---
(0075497)
hudsonbot   
2015-03-12 17:10   
A changeset related to this issue has been promoted main and to the
Central Repository, after passing a series of tests.

Promotion changeset: https://code.openbravo.com/erp/devel/main/rev/4f8a4e2f76d2 [^]
Maturity status: Test
(0075519)
alostale   
2015-03-13 09:34   
code reviewed

tested with 300k rows in ad_session: big improvement from ~30s to ~30ms. Note additional benefit: improvement is not only in the execution plan but also preventing tons of unneeded updates session_active='N' -> session_active='N' which cause disk writes.