SQL Performance: returning scalar from select on complex view VS same select inside pl/sql function
Hi Community.
I have a performance problem which I don't understand:
I have a very Complex view which joins various tables.
This:
SELECT value
FROM View
WHERE x=?
AND y=?
returns exactly 1 row, every join works index based according to explain plan.
If I do this select directly in sqldeveloper it takes some time and show some costs.
If I do the same select inside a pl/sql function and return the "value",
and SELECT function(x,y) FROM dual, it works much faster and explain plan shows much lower cost.
(no caching issue)
Can someone explain why this happens?