Hi guys,
I have a issue with xsjs SQL performance.
I have a simple sql query,
SELECT count(*) FROM "demo"."demo::view" WHERE "StateID"=5
It finishs execution in 400 ms in HANA SQL console.
When I put the query in xsjs,
conn = $.db.getConnection();
query = 'SELECT count(*) FROM "demo"."demo::view" WHERE "StateID"=5';
pstmt = conn.prepareStatement(query);
rs = pstmt.executeQuery();
The xsjs service also responds in 400 ms.
However, if I get request parameter and use the parameter to compose the query with pstmt.setInteger()
stateID = $.request.parameters.get('StateID');
conn = $.db.getConnection();
query = 'SELECT count(*) FROM "demo"."demo::view" WHERE "StateID"=?';
pstmt = conn.prepareStatement(query);
pstmt.setInteger(1, stateID);
rs = pstmt.executeQuery();
The service execution time becomes more than 2.5 seconds.
Do I miss something here on calling sql in xsjs?