I have a query that returns a resultset of three columns, namely SSN,PAID_YEAR and PAID_TOTAL. From this query I can:
- Create a view and then query it.
- Create a function and return resultset
If I go the first way a simple query like the following takes more than 20 seconds:
SELECT PAID_YEAR,PAID_TOTAL FROM VIEW_1 WHERE SSN=12345678912882;
I know that is because when I query a view the engine first brings all the rows of the view and then it filters the rows for the criteria supplied.
If I go the second way I can send a parameter and make the engine look only for those rows that match the condition and return the recordset. But I do not know how to then SELECT from that returned resultset. I took a look at pipelined tables but didn't quite get how to benefit them. So my ultimate question is if it's somehow possible to select from the resultset that is returned from a function like this:
SELECT * FROM FUNCTION_1(12132323232).
If yes, then how, if no, what would be an alternative way?
EDIT:Here's the explain plan: