Monitor Oracle query plans for PARTITION LIST (ALL)

oraclepartitioning

Is there any way I can monitor all the queries running on an Oracle instance and report which queries are using PARTITION LIST (ALL)?

What I'm essentially asking for is a way to automatically EXPLAIN PLAN on every query, then search the plan results for queries that are not eliminating partitions properly.

Best Answer

I would write a job procedure which would get all running queries:

SELECT sql_id, sql_child_number FROM V$SESSION WHERE SQL_ID IS NOT NULL AND TYPE='USER';

and then loop through that cursor and get explain plan

select * from table(dbms_xplan.display_cursor(v_sql_id, v_sql_child_number));