




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、24.oracle深度学习笔记一一使用存储提纲oracle存储提纲(stored outline )用来提供稳定的执行计划,以消除执行环境或者对象统计信息的改变造成的影响。因此,这个特性也被称作计划稳定性。具体的讲,存储提纲是一个提示的集合,更精确地说,所有这些提示强制查询优化器为一个给定的sql语句,稳定地产生一个特殊的执行计划。但实践中,即使使用存储提纲, 还是可能观察到执行计划的改变。不是总能提供一个稳定的执行计划,oracle 11g版本起,不再赞成使用存储提纲,而是推荐sql计划基线。在cbo之后不久被引入,最早基于提示的机制。9i对大纲进行了增强,10gr1后就没有对该特性做过任何
2、事情了。在11g官方文档中称该特性已经被弃用不再维护了。我们先来看看如何使用的如下:1.测试一在12.1.0.2.0版本上进行的测试tpcctoaddb create table oln_test as select * from dba_tables;table created.tpcctoaddb create index idex_oln on oln_test (table_name); index created.tpcctoaddb set autotrace on;tpcctoaddb select owner from oln_test where table_name = o
3、ln_test; no rows selected execution planplan hash value: 2108416138| id | operation| name | rows | bytes | cost (%cpu)| time |0 | select statement|1 |26 |2(0)|00:00:01 |1 | table access by index rowid batched| oln_test | 1 |26 |2(0)| 00:00:01 |*2 | index range scan| idex_oln |1 |1(0)|00:00:01 |predi
4、cate information (identified by operation id):2 - access(table_name=oln_test) statistics98 recursive calls 0 db block gets73 consistent gets6 physical reads0 redo size341 bytes sent via sql*net to client540 bytes received via sql*net from client1 sql*net roundtrips to/from client0 sorts (memory)0 so
5、rts (disk)0 rows processed然后加入hint如下:tpcctoaddb select /*+full(oln_test)*/ owner from oln_test where table_name = oln_test;no rows selectedexecution planplan hash value: 1307524366| id | operation | name | rows | bytes | cost (%cpu)| time |0 | select statement|1 |26 |30(0)| 00:00:01 |*1 | table acce
6、ss full| oln_test | 1 |26 |30(0)| 00:00:01 |predicate information (identified by operation id):1 - filter(table_name=oln_test) statistics1 recursive calls0 db block gets98 consistent gets95 physical reads 0 redo size341 bytes sent via sql*net to client540 bytes received via sql*net from client1 sql*
7、net roundtrips to/from client0 sorts (memory)0 sorts (disk) 0 rows processed1.1 创建 outline生成存储提纲如下:tpcctoaddb set autotrace off;tpcctoaddb createor replaceoutline oln_to on select owner from oln_test where table_name = oln_test;outline created.tpcctoaddb createor replaceoutline oln hint on select /*
8、+full(oln test)*/ owner from oln_test where table_name = oln_test;outline created.1.2 交换 outline直接更新dba_outline除 查看 dba_outline及口下: systoaddb desc dba_outlines;namenull? typenamevarchar2(128)ownervarchar2(128)categoryvarchar2(128)usedvarchar2(6)timestampdateversionvarchar2(64)sql_textlongsignaturera
9、w(16)compatiblevarchar2(12)enabledvarchar2(8)formatvarchar2(6)migratedvarchar2(12)systoaddb select count(*) from dba_outlines;count(*)2tpcctoaddb select name,sql_text from dba_outlines;name sql_textoln_to select owner from oln_test where table_name = oln_test oln_hint select /*+full(oln_test)*/ owne
10、r from oln_test where table_name = oln_test当前共两行,就是我们之前创建的两项。交换可以使用如下命令进行:systoaddbupdatedba_outlinessetname=decode(name,oln_hint,oln_to,oln_to,oln_hint) where name in (oln_to,oln_hint); 2 rows updated. systoaddb commit; commit complete. tpcctoaddb select name,sql_text from dba_outlines;namesql text
11、oln_hint select owner from oln_test where table_name = oln_testoln_to select /*+full(oln_test)*/ owner from oln_test where table_name = oln_test 检验如下:tpcctoaddb alter system flush shared_pool;tpcctoaddb set autotrace on;12c 需要设置:systoaddb alter system set use stored outlines=true;tpcctoaddb select o
12、wner from oln_test where table_name = oln_test;no rows selectedexecution planplan hash value: 1307524366| id | operation | name | rows | bytes | cost (%cpu)| time |0 | select statement|1 |26 |30(0)| 00:00:01 |*1 | table access full| oln_test | 1 |26 |30(0)| 00:00:01 |predicate information (identifie
13、d by operation id):1 - filter(table_name=oln_test) note-outline oln_hint used for this statement statistics0 recursive calls0 db block gets98 consistent gets0 physical reads0 redo size341 bytes sent via sql*net to client540 bytes received via sql*net from client0 sql*net roundtrips to/from client0 s
14、orts (memory)0 sorts (disk)0 rows processed删除 outlinetpcctoaddb drop outline oln_to;outline dropped.tpcctoaddb drop outline oln_hint;outline dropped.1.3 通过 shared pool 中 sql 仓|建 outline需要10g以上,蛤蟆在12c上进行的操作tpcctoaddb select count(*) from oln_test;count(*)2476tpcctoaddb col sql_id format a20;tpcctoadd
15、b col sql_text format a40;tpcctoaddb select sql_id,hash_value, child_number, sql_text from v$sql where sql_text like select count(*) from oln_test%;sql_idhash_value child_number sql_text24z60pxhd61h916244423770 select count(*) from oln_test使能会话创建存储提纲tpcctoaddb alter session set create_stored_outline
16、s = true;session altered.通过sql的hash值来创建存储提纲如下:tpcctoaddb exec dbms_outln.create_outline(hash_value = 1624442377,child_number =0);pl/sql procedure successfully completed.执行检查测试如下:tpcctoaddb select name,sql_text from dba_outlines;name sql_textsys_outline_160 select count(*) from oln_test 3051713221981
17、9sys_outline_160 select sql_id,hash_value, child_number, 30517132615720 sql_text from v$sql where sql_text like select count(*) from oln_test%sys_outline_160 select count(*) from dba_outlines 30517140764322sys_outline_160 select name,sql_text from dba_outlines 30517143173123tpcctoaddbset autotrace o
18、n;tpcctoaddb select count(*) from oln_test;count(*)2476execution planplan hash value: 2860217201| id | operation| name | rows | cost (%cpu)| time |0 | select statement |1 |5(0)| 00:00:01 |1 | sort aggregate |1 |5(0)| 00:00:01 |2 | index fast full scan| idex_oln |2476 |note-outline sys_outline_16030516461948302 used for this statementstatistics0 recursive calls0 db block gets0
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 第五第六的单元数学试卷
- 肉鸽生产技术课件
- 爱上阅读 品味文字 主题班会课件
- 2025年03月重庆市人民医院招聘131人笔试历年专业考点(难、易错点)附带答案详解
- 2025年黑龙江大庆市杜尔伯特蒙古族自治县社区卫生服务中心招聘医学毕业生8人笔试历年专业考点(难、易错点)附带答案详解
- 2025年05月云南省楚雄州大姚县紧密型医共体妇幼保健分院编外聘用人员招聘(2人)笔试历年专业考点(难、易错点)附带答案详解
- 长城汽车培训课件
- 2025至2030船用导航雷达行业市场深度研究及发展前景投资可行性分析报告
- 2025至2030厨电产业行业市场深度研究及发展前景投资可行性分析报告
- 高考最高数学试卷
- 第二章第二节《中国篆刻艺术》(教案)中职美术《艺术美术鉴赏与实践》同步教案(高教版(2023)(修订版))
- 精神科一科一品一特色护理
- 【9物二模】深圳市2025年4月份九年级中考第二次模拟测试物理试卷(含答案)
- 四川省成都市双流县2024-2025学年三下数学期末复习检测模拟试题含解析
- 2025-2030溶剂型3C涂料行业市场现状供需分析及投资评估规划分析研究报告
- 福建省职业院校技能大赛高职组(健身指导赛项)考试题(附答案)
- 大学生创业之星路演
- 永州斑马乐器厂薪酬方案优化设计
- 太原饮食文化的国际传播与旅游推动
- 实验室生物安全整改措施
- 下肢深静脉血栓形成介入治疗护理实践指南(2025版)解读课件
评论
0/150
提交评论