这个包创建并执行了一个名为 FOLIO_COUNT 的调整任务。接下来,您将需要查看任务执行的结果(也就是说,查看建议)。 set serveroutput on size 999999 set long 999999 select dbms_sqltune.report_tuning_task ('FOLIO_COUNT') from dual;
中级调整:查询重构 假定查询更复杂: select account_no from accounts a where account_name = 'HARRY' and sub_account_name not in ( select account_name from accounts where account_no = a.old_account_no and status is not null);
顾问建议如下: 1- RestrUCture SQL finding (see plan 1 in eXPlain plans section) ---------------------------------------------------------------- The optimizer could not unnest the subquery at line ID 1 of the execution plan.
Recommendation -------------- Consider replacing "NOT IN" with "NOT EXISTS" or ensure that columns used on both sides of the "NOT IN" Operator are declared "NOT NULL" by adding either "NOT NULL" constraints or "IS NOT NULL" predicates.
Rationale --------- A "FILTER" operation can be very expensive because it evaluates the subquery for each row in the parent query.The subquery, when unnested can drastically improve the execution time because the "FILTER" operation is converted into a join.Be aware that "NOT IN" and "NOT EXISTS" might produce different results for "NULL" values.
这一次顾问不会建议任何结构上的更改(如索引),但会通过用 NOT EXISTS 取代 NOT IN的方式很聪明地猜测到调整查询的正确方式。 由于两种构造相似但不相同,顾问给出了这种改变的基本原理,并把决定权留给 DBA 或应用程序开发人员,由他们决定该建议是否对环境有效。