一个问题:CDS view在HANA studio里执行,显示的耗时比在ABAP open SQL里少

简介: 一个问题:CDS view在HANA studio里执行,显示的耗时比在ABAP open SQL里少

Sent: Samstag, 8. Juli 2017 11:03

Subject: RE: have a quick discussion about why the CDS view has a bad performance displayed in ST05 or SAT but the trace displayed in HANA studio shows a good performance


Thanks a lot for your support.


I have executed the report repeatedly for 5 times and the average time in ABAP is still 16 seconds.

image.png



And when the SQLScript is executed in HANA studio, only 2.4 seconds is consumed.

I plan to create an incident to HANA.


Can you please kindly suggest the correct component to create incident? Thanks a lot!



image.png

分析方法

Hi Jerry,

there is certainly something which can explain the difference. But sometimes it’s difficult to find the root cause.

One possible reason might be the fact, that from ABAP we use host variables ( where xy = ? instead of where xy = ‘4711’).


If this is identical switch on the expensive statement trace for both cases and try to see, if there is anything visible as a difference.


Jerry的分析 - Sent: Donnerstag, 13. Juli 2017 09:01

Subject: RE: have a quick discussion about why the CDS view has a bad performance displayed in ST05 or SAT but the trace displayed in HANA studio shows a good performance


Hi Heiko,


The HANA colleague in the incident told me the reason of this difference. I copied the reply to this mail for you ( in blue ):


“It’s the performance gap between prepared statement and non-prepared statement, when LIMIT is invovled.


You may know that sql optimizer in HANA is rule-based, during execution plan generation for the non-prepared statement, PRELIMIT_BEFORE_JOIN rule can be applied to constant LIMIT operator. But cannot be applied to parameterized LIMIT cases for technical reason, unless we are well aware of how much records could be pruned with LIMIT operator, we cannot estimate its cost and decide the optimal plan based on the estimated cost.


解决方案: using fixed LIMIT value.

p.s:


Prepared statement:image.pngnon-prepared statement:image.pngWhen I use the fixed limit – I hard coded 100 – in the code, the performance in ABAP becomes equal in HANA studio – 2 seconds to finish the query.



image.png

However in CRM WebUI, this limit is specified by end user, it seems we should not hard code it.



image.png

And in S4 Fiori Search, the limit is not used any more.



image.png

When end user clicks search in S4, the total number of found product is displayed and only the first 25 product is returned from backend.



image.pngimage.png


This paging logic could be observed in Chrome:



image.png

When end user scrolls to the bottom of search list, another 25 products will be fetched. I will discuss this difference with Carsten.


image.png


#德国同事的建议 - 使用hint


Hi Jerry,

ah, I see. As suspected a difference between prepared / non-prepared statements. And the problem with the limits as host variables is not showing up the first time.


Maybe we can solve this with a hint. On other DBs we always had the possibility to specify something like an optimization target “optimize for first rows”, which means that the optimizer should choose a plan, which is optimal for a small number of records.


WITH HINT (PRELIMIT_BEFORE_JOIN)


The limit pushdown for parameter value is triggered only if the above hint is given.


P.S.

HANA optimizer is not rule-based but cost-based optimizer. Just for clarification.


令人感到悲伤的是,这个hint在我的场景里没法工作。


From: Wang, Jerry


Sent: Monday, July 17, 2017 7:38 AM

Hi SungHeun,


Sorry for late reply as I am on vacation currently. Thanks a lot for your kind suggestion.


Unfortunately, I guess this hint will not work in my case, as I am using SELECT DISTINCT on the CDS view, which will prevent limit push down even if the hint is applied.


Here below is the hint I have added according to your kind suggestion:

image.png

And in the runtime, it still takes more than 200 seconds to finish the query:

image.png


相关文章
|
20天前
|
SQL 数据库 索引
关于 SAP ABAP REPOSRC 数据库表在 HANA 中的 DDL Definition
关于 SAP ABAP REPOSRC 数据库表在 HANA 中的 DDL Definition
18 1
关于 SAP ABAP REPOSRC 数据库表在 HANA 中的 DDL Definition
|
6月前
|
数据库
什么是 SAP ABAP CDS view 的 Filtered association?
什么是 SAP ABAP CDS view 的 Filtered association?
33 0
|
6月前
|
SQL 网络协议 数据库连接
在 ABAP 层执行 Open SQL 的幕后操作 - 武侠版
在 ABAP 层执行 Open SQL 的幕后操作 - 武侠版
35 0
|
2月前
|
SQL 数据库
小技巧:如何让 ABAP OPEN SQL 代码具有自解释性(Self-Explained)
小技巧:如何让 ABAP OPEN SQL 代码具有自解释性(Self-Explained)
25 0
|
20天前
|
数据库 存储 BI
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
11 0
SAP ABAP CDS View 源代码存储的数据库表揭秘和其他相关数据库表介绍试读版
|
20天前
|
数据库
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
9 0
迈入 SAP CDS View 世界的前置知识 - SAP ABAP 数据库视图介绍试读版
|
20天前
|
数据库 SQL 应用服务中间件
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
20 0
SAP ABAP CDS View 和 HANA CDS View 相同点和不同点辨析
|
6月前
|
SQL 数据库 数据安全/隐私保护
SAP CDS view 定义的数据库视图和传统 SQL 语句定义视图的区别
SAP CDS view 定义的数据库视图和传统 SQL 语句定义视图的区别
73 0
|
3月前
|
SQL Shell 数据库
无人参与安装最新版本SQL Server Management Studio (SSMS)
通过power shell完成SSMS的自动安装,给大家争取打水的时间,离开位置走走,活动活动筋骨。
34 0
|
5月前
|
SQL 安全 数据库
关于 ABAP OPEN SQL 注入漏洞的防御
关于 ABAP OPEN SQL 注入漏洞的防御
33 0

热门文章

最新文章