Here is an example view named MANVW:
SELECT manager_id, manager_sign
FROM (
SELECT manager_id, manager_sign, effdt
MAX(effdt) OVER (PARTITION BY manager_id) AS max_dt
FROM managers)
WHERE effdt = max_dt;
Here is my query:
SELECT * from MANVW where manager_sign = 'ABC';
Unfortunately, when I query this view it builds the entire inline view (where the analytic function is) and does not use the index on manager_sign.
If I used a nested select for the MANVW, it does use the index:
SELECT m.manager_id, m.manager_sign
FROM managers m
where m.effdt = (select max(mi.effdt) from managers mi where mi.manager_id = m.manger_id)
The trade-off is that using analytic functions I can retrieve all records in the view quickly, but it is slow if I am retrieving only a subset of the records filtered by an indexed column. I would like the analytic function to use predicate pushing so that it would be quick when used this way.
Is it possible to have a view that uses analytic functions, and will push predicates where possible?
I guess I did not search long enough before asking my question, because somebody already asked Tom the exact same question: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3469884600671