2016 May 25 1:21 PM
Dear experts,
I am preparing custom SAP code for HANA and found the following:
1. Not only pool and cluster tables are affected, but also transparent ones (We have a customer on HANA who reported such cases).
2. SCI Code Inspector cannot find such code in all cases:
Currently there is a check: "Search problematic statements for result of SELECT/OPEN CURSOR without ORDER BY",
but! It works only if you perform specific operations after "SELECT .. INTO TABLE", for example:
* READ TABLE itab ... BINARY SEARCH
* DELETE ADJECENT DUPLICATES FROM itab
and etc. (they are all mentioned in the description of SCI Inspector check).
So if you just have a select into table without order by, but no specific operations mentioned in description if SCI check,
you code is not optimized for HANA and you are not aware of it. This select will not appear in Code Inspector result list.
For example, if we show documents list using just a select from table and immediately sending results to ALV, then user will see unsorted documents list.
Please advise how could such situations be found
2016 May 25 2:21 PM
I think you mix up functional correctness and hana optimizations.
The order by is necessary for following operations that rely on the sorting.
When you do not need the ordering, then it is surely faster if you do not add an ORDER BY.
- Thomas
2016 May 25 2:00 PM
Hi experts,
I think I found a way for it:
In the Code Inspector, I configured one more pattern (additionally to standard HANA ones):
Now I get results and could adjust them as required. Please let me know if you have other and better alternatives
2016 May 25 2:21 PM
I think you mix up functional correctness and hana optimizations.
The order by is necessary for following operations that rely on the sorting.
When you do not need the ordering, then it is surely faster if you do not add an ORDER BY.
- Thomas
2016 May 25 2:52 PM
Hi Thomas,
I think I did not explain the situation correctly.
For sure you do not need "ORDER BY" always.
But "ORDER BY" is needed not only if you perform operations that rely on sort after the select.
For example, you prepare a list of documents to show to the user. In the code, you just have a statement "Select * from <some header table". No more operations are performed.
Before HANA results were retrieved with sorting on table key fields.
But now in HANA user will see unsorted documents list. This is a known issue from one of the customers with HANA.
So in order to find such situations, I enhanced the SCI check. This does not mean I will add "ORDER BY" or "SORT" to all cases found by SCI, but check each case individually.
I wonder if there is any other option to handle this in a better way
I hope I explained it better this time
2016 Jun 02 8:35 AM
Dear experts,
in the end I implemented a new custom code inspector check, which checks if the select was done into a standard table, if key fields were selected, and if no sorting or order by was used for it.
I hope it helps the others.