Oracle: 执行计划中的Nested Loops
一个Nested Loops操作总是有两个孩子,第一个孩子(即较上面的那行)叫outer loop,第二个叫inner loop 具体执行顺序是: 1. 执行outer loop, 返回rowSet-outer 2. for every row in rowSet-outer 执行inner loop end for 3. 将inner loop多次操作产生的结果总集返回给父操作,即Nested Loops操作
一个Nested Loops操作总是有两个孩子,第一个孩子(即较上面的那行)叫outer loop,第二个叫inner loop 具体执行顺序是: 1. 执行outer loop, 返回rowSet-outer 2. for every row in rowSet-outer 执行inner loop end for 3. 将inner loop多次操作产生的结果总集返回给父操作,即Nested Loops操作
执行这样的SQL: #1 explain plan for select * from student; select * from table(dbms_xplan.display); 这样可以看到CBO估计出的值 #2 select /*+ gather_plan_statistics */ * from student where student_id < 3 and 1 = 2; select sql_id from v$sql where sql_text like ‘ select /*+ gather_plan_statistics */ * from student where student_id < 3 and 1 = 2%’; select * …
优化器会根据对象的统计信息来决定执行计划,因此这个信息很重要。 SQL: –查看表的stats select * from user_tab_statistics where table_name = ‘STUDENT’ –查看列的stats select * from user_tab_col_statistics where table_name = ‘STUDENT’ –查看索引的stats select * from user_ind_statistics where table_name = ‘STUDENT’
Oracle 10g开始不再支持RBO (rule-based optimizer),而只支持 CBO (cost-based optimizer)
http://www.allroundautomations.com/plsprofiler.html The Profiler is easily accessible in the Debugger’s Test Window. Before executing a Test Script, simply press the Create Profiler report button on the toolbar. If you subsequently execute the script, you can switch to the Profiler page to view the report.
以trace文件为核心 1. 先找出追踪文件的位置 select * from v$parameter where name = ‘user_dump_dest’ 2. 把追踪文件格式化一下 a. 下载 http://antognini.ch/downloads/tvdxtat_40beta9.zip (Christian Antognini 写的格式化工具,他说这个比Oracle自带的好用) b. 这是一个JAVA程序。请解压然后编辑其中的bat文件,设置一下相关的目录 (xxx_home) c. 运行一下: 比如: tvdxtat -i C:\oraclexe\app\oracle\admin\XE\udump\xe_ora_7424.trc -o output\result.html -s no -w yes d. 最后,研究一下 result.html
系统换版前要征得合作方同意 1.换版可能失败,这会导致合作方的业务受阻。所以要先打好招呼。 2.合作方的系统跟你的系统存在交互,你的系统升级时要让对方跟你一起升级。 3.不管是测试环境换版还是生产环境换版,都要先征得合作方同意。测试环境对他们来说可能有重要的意义。