Skip to Content
0
Oct 12, 2019 at 10:15 AM

Eclipse ABAP SQL console not always uses SQL binding parameters

229 Views

When I was testing ABAP CDS views in Eclipse ABAP SQL console, I noticed that when I changed the value of a WHERE clause parameter, the query was the first time slow and the second time fast.
The cause is that after the value is changed, a new Execution Plan is compiled.
The cause of that, is because the WHERE clause parameter is not always transferred to HANA as a binding parameter but as a literal parameter. In other cases is does generate a binding parameter and there is no new Execution Plan compiled.

I created a simple query on VBAP to show the problem.
And below that query the query of the Plan cache is shown.

1. Only parameter VBELN is transferred and it is transferred as literial parameter.

SELECT * FROM VBAP WHERE VBELN = '0000004900' 
SELECT /* FDA READ */ * FROM "VBAP" WHERE "MANDT" = ? AND "VBELN" = N'0000004900' LIMIT 100 

2. Parameter VBELN and POSNR are transferred and VBELN is transferred as literal and POSNR as binding variable.

SELECT * FROM VBAP WHERE VBELN = '0000004900' AND POSNR = '000010' 
SELECT /* FDA READ */ * FROM "VBAP" WHERE "MANDT" = ? AND "VBELN" = N'0000004900' AND "POSNR" = ? LIMIT 100 

3. Now only POSNR is used, and it is transferred as binding parameter.

SELECT * FROM VBAP WHERE POSNR = '000010' 
SELECT /* FDA READ */ * FROM "VBAP" WHERE "MANDT" = ? AND "POSNR" = ? LIMIT 100 

VBELN is a CHAR field. POSNR is a NUMC field. Maybe that's the cause.

Is there a way to force that VBELN is also transferred as binding parameter?