Anonymous | Login
Project:
RSS
  
News | My View | View Issues | Roadmap | Summary

View Issue DetailsJump to Notes ] Issue History ] Print ]
ID
0027141
TypeCategorySeverityReproducibilityDate SubmittedLast Update
defect[Openbravo ERP] 07. Sales managementminoralways2014-07-21 17:012014-08-18 13:34
ReportervmromanosView Statuspublic 
Assigned Tovmromanos 
PrioritynormalResolutionfixedFixed in Version
StatusclosedFix in branchpiFixed in SCM revision796652fcb518
ProjectionnoneETAnoneTarget Version3.0PR14Q4
OSLinux 32 bitDatabasePostgreSQLJava version1.6.0_12
OS VersionDebian 5.0Database version8.3.8Ant version1.7.0
Product VersionSCM revision 
Review Assigned Torafaroda
Web browser
ModulesCore
Regression level
Regression date
Regression introduced in release
Regression introduced by commit
Triggers an Emergency PackNo
Summary

0027141: Minor performance fix in C_ORDERLINETAX_TRG

DescriptionThe C_ORDERLINETAX_TRG trigger contains the following SQL query:

SELECT COUNT(C_TAX_ID) INTO v_Count
FROM C_ORDERTAX
WHERE C_ORDER_ID = :NEW.C_Order_ID
AND C_TAX_ID = :NEW.C_TAX_ID;

Later on there is an IF clause that checks v_Count > 0.

In this scenario where we are not interested in the exact number of records, it's better from a performance perspective to use COUNT(1) instead.
Steps To ReproduceUsing PG:
-Enable function statistics:
  -In postgresql.conf set track_functions = all
  -/etc/init.d/postgresql reload

1. Create a sales order with a great number of lines (for example 400).
2. Reset pg statistics: select pg_stat_reset();
3. Book the order
4. Check function calls: select funcname, calls, total_time, self_time from pg_stat_user_functions order by self_time desc
5. Verify the total_time for C_ORDERLINETAX_TRG
6. Apply the proposed solution
7. Verify the total_time for C_ORDERLINETAX_TRG has decreased.
Proposed SolutionUse Count(1)
TagsPerformance
Attached Files

- Relationships Relation Graph ] Dependency Graph ]
blocks defect 0027160 closededuardo_Argal C_Order_Post poor performance 

-  Notes
(0068807)
hgbot (developer)
2014-07-22 15:12

Repository: erp/devel/pi
Changeset: 796652fcb518b93f0ffb193a69ffafe6a0d997be
Author: Víctor Martínez Romanos <victor.martinez <at> openbravo.com>
Date: Tue Jul 22 10:22:19 2014 +0200
URL: http://code.openbravo.com/erp/devel/pi/rev/796652fcb518b93f0ffb193a69ffafe6a0d997be [^]

Fixed bug 27141: Minor performance fix in C_ORDERLINETAX_TRG

---
M src-db/database/model/triggers/C_ORDERLINETAX_TRG.xml
---
(0069075)
dmitry_mezentsev (developer)
2014-08-04 16:36

The issues is not closed for 13 days now!!!
(0069210)
hudsonbot (developer)
2014-08-08 18:53

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/4450016dee64 [^]
Maturity status: Test
(0069274)
eduardo_Argal (developer)
2014-08-08 19:50

I would try this query:

select 1 from dual where exists (select 1 FROM C_ORDERTAX
WHERE C_ORDER_ID = :NEW.C_Order_ID
AND C_TAX_ID = :NEW.C_TAX_ID)

this one could be faster, but for an order and a certain tax order tax should hold one single entry. There is just one exception to this rule, which is to enter and adjustment manually.
(0069458)
rafaroda (developer)
2014-08-18 13:34

Code reviewed + functionally tested with Cash VAT and regular Sales Orders.

- Issue History
Date Modified Username Field Change
2014-07-21 17:01 vmromanos New Issue
2014-07-21 17:01 vmromanos Assigned To => vmromanos
2014-07-21 17:01 vmromanos Modules => Core
2014-07-21 17:01 vmromanos Triggers an Emergency Pack => No
2014-07-21 17:01 vmromanos Tag Attached: Performance
2014-07-21 17:01 vmromanos Status new => scheduled
2014-07-21 17:01 vmromanos fix_in_branch => pi
2014-07-22 15:12 hgbot Checkin
2014-07-22 15:12 hgbot Note Added: 0068807
2014-07-22 15:12 hgbot Status scheduled => resolved
2014-07-22 15:12 hgbot Resolution open => fixed
2014-07-22 15:12 hgbot Fixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/796652fcb518b93f0ffb193a69ffafe6a0d997be [^]
2014-07-23 08:26 alostale Relationship added blocks 0027160
2014-07-23 10:58 mtaal Issue Monitored: mtaal
2014-08-04 16:36 dmitry_mezentsev Note Added: 0069075
2014-08-08 18:53 hudsonbot Checkin
2014-08-08 18:53 hudsonbot Note Added: 0069210
2014-08-08 19:50 eduardo_Argal Note Added: 0069274
2014-08-18 13:34 rafaroda Review Assigned To => rafaroda
2014-08-18 13:34 rafaroda Note Added: 0069458
2014-08-18 13:34 rafaroda Status resolved => closed


Copyright © 2000 - 2009 MantisBT Group
Powered by Mantis Bugtracker