是否可以检查在 PLSQL 块内执行的 SQL 语句的执行计划?
DECLARE
l_count PLS_INTEGER;
BEGIN
SELECT COUNT(1) INTO l_count
FROM foo;
END;
/
对于常规 SQL,我通常会运行以下命令来检查执行计划:
select * from table(dbms_xplan.display_cursor(null, null, 'ALLSTATS LAST'));
但是,这只是报告:
NOTE: cannot fetch plan for SQL_ID: 3q0sujncq54wy, CHILD_NUMBER: 0
Please verify value of SQL_ID and CHILD_NUMBER;
It could also be that the plan is no longer in cursor cache (check v$sql_plan)