Openbravo Issue Tracking System - Openbravo ERP
View Issue Details
0022292Openbravo ERPA. Platformpublic2012-11-14 11:112013-01-02 11:16
alostale 
shankarb 
normalmajorN/A
closedfixed 
5
 
3.0MP193.0MP19 
AugustoMauch
Core
No
0022292: Grid: order DESC PK column when other columns are DESC
When querying for data to be shown in grids, in addition to the columns that participate in the order by, pk column of the queried table is always appended to the order by clause. This is done in order to preserve a constant sorting of records among different pages.

The problem is in case of big volume tables, to be possible to use index for the sorting, it needs to be a multi-column index including both columns: the one we actually want to sort + PK column.

When working with compound indexes the way the column in the index is sorted (asc or desc) matters. Meaning that if the index is created as [colA asc, colB asc], it cannot be used for order by A desc, B asc. But it would be possible to use that index for order by A desc, B desc.

For example:

M_Transaction table with a compound index (date + pk) both asc

order by MovementDate desc, M_Transaction_ID -> index IS NOT applied
order by MovementDate desc, M_Transaction_ID desc -> index IS applied
-
Change data source so in case all columns are ordered desc, pk ordering is also desc. In this way we can add just one compound index instead of 2.
No tags attached.
diff FixIssue22292.diff (1,728) 2012-11-30 06:06
https://issues.openbravo.com/file_download.php?file_id=5777&type=bug
Issue History
2012-11-14 11:11alostaleNew Issue
2012-11-14 11:11alostaleAssigned To => AugustoMauch
2012-11-14 11:11alostaleModules => Core
2012-11-23 08:08alostaleStatusnew => scheduled
2012-11-23 08:08alostaleTarget Version => 3.0MP19
2012-11-30 06:00shankarbAssigned ToAugustoMauch => shankarb
2012-11-30 06:06shankarbFile Added: FixIssue22292.diff
2012-12-24 06:34shankarbIssue Monitored: AugustoMauch
2012-12-24 06:34shankarbReview Assigned To => AugustoMauch
2012-12-24 06:34shankarbTriggers an Emergency Pack => No
2012-12-24 06:41shankarbNote Added: 0055162
2012-12-24 06:42hgbotCheckin
2012-12-24 06:42hgbotNote Added: 0055163
2012-12-24 06:42hgbotStatusscheduled => resolved
2012-12-24 06:42hgbotResolutionopen => fixed
2012-12-24 06:42hgbotFixed in SCM revision => http://code.openbravo.com/erp/devel/pi/rev/9c66708f78ef7484efee6c25ecd1f187eda3c599 [^]
2012-12-26 15:43hudsonbotCheckin
2012-12-26 15:43hudsonbotNote Added: 0055212
2013-01-02 11:16AugustoMauchNote Added: 0055304
2013-01-02 11:16AugustoMauchStatusresolved => closed
2013-01-02 11:16AugustoMauchFixed in Version => 3.0MP19

Notes
(0055162)
shankarb   
2012-12-24 06:41   
Test Plan:
1. Open any window.
2. Order a column in grid in descending.
3. Debug in buildQuery() method in DataEntityQueryService.java.
4. The where clause that is generated will be 'COLUMN_NAME desc, id desc'.
(0055163)
hgbot   
2012-12-24 06:42   
Repository: erp/devel/pi
Changeset: 9c66708f78ef7484efee6c25ecd1f187eda3c599
Author: Shankar Balachandran <shankar.balachandran <at> openbravo.com>
Date: Fri Nov 30 10:36:22 2012 +0530
URL: http://code.openbravo.com/erp/devel/pi/rev/9c66708f78ef7484efee6c25ecd1f187eda3c599 [^]

Fixes Issue 0022292: Order PK column in DESC when other columns are DESC

In Grid, ordering primary key column in descending when all other order by columns are in descending.
This is done to use the index for sorting.

---
M modules/org.openbravo.service.json/src/org/openbravo/service/json/AdvancedQueryBuilder.java
---
(0055212)
hudsonbot   
2012-12-26 15:43   
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/631fc2e1c525 [^]

Maturity status: Test
(0055304)
AugustoMauch   
2013-01-02 11:16   
Code reviewed and verified in pi@6735d51a4790