I have a procedure with a complex SQL query within it...
create procedure myproc (IN mylevel integer, OUT res MY_RESULT) LANGUAGE SQLSCRIPT SQL SECURITY DEFINER READS SQL DATA AS
BEGIN
res = select <complex query involving numerous tables>;
END;
When I call the procedure from the console it takes about 10 seconds:
call myproc (4, ?)
But when I just run the SELECT statement directly (with '4' substituted into the relevant place in the SQL), it takes less than a second.
It seems as though the optimiser might be doing things completely differently in the two scenarios??
It isn't really possible for me to compare the 'explain plan' for the SELECT, and the 'visualise plan' for the CALL, as the query is too complex and the formal of 'visualise plan' and 'explain plan' is too different. And I cant seem do an 'explain plan' for a 'call' statement, not allowed, it seems.
So I am just wanting to know if this is known Hana behaviour: a SELECT behaving differently than a PROCEDURE that just wraps that select? What is going on here?
thanks
David