9i,10g 优化器动态采样级别参数 -- optimizer_dynamic_sampling (统计优化)

本文详细介绍了Oracle数据库中动态采样的工作原理及其不同级别设置的影响。动态采样可以帮助优化器在未分析的表上生成更准确的执行计划,减少因统计信息缺失导致的执行计划错误。

             我们经常会碰到由于一些表没有分析导致执行计划错误的情况,但是Oracle9.2 中dynamic sampling的出现一定程度的减少了错误的产生。dynamic sampling针对没有分析过的表可以采样估计表的选择性,对于生产正确的执行计划有一定的帮助。 

           优化器动态采样级别参数 optimizer_dynamic_sampling ,是在Oracle9.2.0 版本之后才有的。设置级别可以由0到10, 0表示不进行动态采样, 10 表示采样级别最高。 Oracle9.2或以上(9i)下参数 optimizer_dynamic_sampling 默认值是1,Oracle10g 下默认值是2 。

Level 0:   Do not dynamically sample the table(s)   不进行动态采样 。

Level 1: Sample tables that have not been analyzed if there is more than one table in the query,the table in question has not been analyzed and it has no indexes,and the optimizer determines that the query plan would be affected based on the size of this objects  

Level 2:    Sample all unanalyzed tables referenced in teh query using default sampling amounts(small sample)

Level 3 -- Level 10     更详细的sample 。

              如果一个表没有统计信息,那么,CBO优化器将采用默认的统计数据,这样是很不准确的, 会直接导致错误的执行计划 。利用optimizer_dynamic_sampling参数,CBO优化器可收集引用对象上足够的统计信息得出更加准确的执行计划。 不过在Oracle9中需要有多表关联的时候optimizer_dynamic_sampling才会起作用,单个表不起作用。在10g中在optimizer_dynamic_sampling >=2  (10g默认是2) 的时候单个表就能实现优化器动态采样 。 

              我们知道,在Oracle9i, 10g中如果选择的是CHOOSE优化模式,那么在没有分析统计信息的时候,Oracle会选择使用RULE 方式,Oracle9i中,如果使用HINT强制用CBO的话,系统会读取一点信息来模拟实际的统计信息。当然Oracle10g 默认的优化模式是CBO ,所以除非人为更改,一般不会走RULE模式。 

               Oracle9i中如果关联的两个表都没有分析,那么  optimizer_dynamic_sampling 不起作用(可以sql trace 测试一下) , 关联的表中有一个分析过了,那么优化器动态采样就起作用了。

              但是Oracle10g中如果两个表都没有分析,optimizer_dynamic_sampling 也会起作用。 以上应该都是由于Oracle10g中已经没有了基于RULE的优化器,在9i中如果一个查询中所有的表都没有分析,那么它会选择rule优化器,而忽略掉  dynamic  sampling  。10g中已经没有了rule ,   没有选择,只有 dynamic  sampling。 

 

--------------------------------------------------------------------------------- 

以下的解释还在理解中,有朋友能很好理解关于采样数据块的请帮忙解释一下 : 

Level 1:    Sample all tables that have not been analyzed if the following criteria are met: (1) there is at least 1 unanalyzed table in the query;    (2) this unanalyzed table is joined to another table or appears in a subquery or non-mergeable view;   (3) this unanalyzed table has no indexes;    (4) this unanalyzed table has more blocks than the number of blocks that would be used for dynamic sampling of this table. The number of blocks sampled is the default number of dynamic sampling blocks (32).  


Level 2:      Apply dynamic sampling to all unanalyzed tables. The number of blocks sampled is the default number of dynamic sampling blocks.

 

 

 

----------------------------------------------------------------------------------------------- 

更加详细的Level :

----------------------------------------------------------------------------------------------- 


Level 0:    Do not use dynamic sampling.
Level 1:    Sample all tables that have not been analyzed if the following criteria are met: (1) there is at least 1 unanalyzed table in the query; (2) this unanalyzed table is joined to another table or appears in a subquery or non-mergeable view; (3) this unanalyzed table has no indexes; (4) this unanalyzed table has more blocks than the number of blocks that would be used for dynamic sampling of this table. The number of blocks sampled is the default number of dynamic sampling blocks (32).
Level 2:      Apply dynamic sampling to all unanalyzed tables. The number of blocks sampled is the default number of dynamic sampling blocks.
Level 3:      Apply dynamic sampling to all tables that meet Level 2 criteria, plus all tables for which standard selectivity estimation used a guess for some predicate that is a potential dynamic sampling predicate. The number of blocks sampled is the default number of dynamic sampling blocks.
Level 4:      Apply dynamic sampling to all tables that meet Level 3 criteria, plus all tables that have single-table predicates that reference 2 or more columns. The number of blocks sampled is the default number of dynamic sampling blocks.
Level 5:      Apply dynamic sampling to all tables that meet the Level 4 criteria using 2 times the default number of dynamic sampling blocks.
Level 6:      Apply dynamic sampling to all tables that meet the Level 5 criteria using 4 times the default number of dynamic sampling blocks.
Level 7:      Apply dynamic sampling to all tables that meet the Level 6 criteria using 8 times the default number of dynamic sampling blocks.
Level 8:      Apply dynamic sampling to all tables that meet the Level 7 criteria using 32 times the default number of dynamic sampling blocks.
Level 9:     Apply dynamic sampling to all tables that meet the Level 8 criteria using 128 times the default number of dynamic sampling blocks.
Level 10:    Apply dynamic sampling to all tables that meet the Level 9 criteria using all blocks in the table.

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-592375/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/35489/viewspace-592375/

已经博主授权,源码转载自 https://pan.quark.cn/s/053f1da40351 在计算机科学领域,MIPS(Microprocessor without Interlocked Pipeline Stages)被视作一种精简指令集计算机(RISC)的架构,其应用广泛存在于教学实践和嵌入式系统设计中。 本篇内容将深入阐释MIPS汇编语言中涉及数组处理的核心概念与实用操作技巧。 数组作为一种常见的数据结构,在编程中能够以有序化的形式储存及访问具有相同类型的数据元素集合。 在MIPS汇编语言环境下,数组通常借助内存地址与索引进行操作。 以下列举了运用MIPS汇编处理数组的关键要素:1. **数据存储**: - MIPS汇编架构采用32位地址系统,从而能够访问高达4GB的内存容量。 - 数组元素一般以连续方式存放在内存之中,且每个元素占据固定大小的字节空间。 例如,针对32位的整型数组,其每个元素将占用4字节的存储空间。 - 数组首元素的地址被称为基地址,而数组任一元素的地址可通过基地址加上元素索引乘以元素尺寸的方式计算得出。 2. **寄存器运用**: - MIPS汇编系统配备了32个通用寄存器,包括$zero, $t0, $s0等。 其中,$zero寄存器通常用于表示恒定的零值,$t0-$t9寄存器用于暂存临时数据,而$s0-$s7寄存器则用于保存子程序的静态变量或参数- 在数组处理过程中,基地址常被保存在$s0或$s1寄存器内,索引则存储在$t0或$t1寄存器中,运算结果通常保存在$v0或$v1寄存器。 3. **数组操作指令**: - **Load/Store指令**:这些指令用于在内存与寄存器之间进行数据传输,例如`lw`指令用于加载32位数据至寄存器,`sw`指令...
根据原作 https://pan.quark.cn/s/cb681ec34bd2 的源码改编 基于Python编程语言完成的飞机大战项目,作为一项期末学习任务,主要呈现了游戏开发的基本概念和技术方法。 该项目整体构成约500行代码,涵盖了游戏的核心运作机制、图形用户界面以及用户互动等关键构成部分。 该项目配套提供了完整的源代码文件、相关技术文档、项目介绍演示文稿以及运行效果展示视频,为学习者构建了一个实用的参考范例,有助于加深对Python在游戏开发领域实际应用的认识。 我们进一步研究Python编程技术在游戏开发中的具体运用。 Python作为一门高级编程语言,因其语法结构清晰易懂和拥有丰富的库函数支持,在开发者群体中获得了广泛的认可和使用。 在游戏开发过程中,Python经常与Pygame库协同工作,Pygame是Python语言下的一款开源工具包,它提供了构建2D游戏所需的基础功能模块,包括窗口系统管理、事件响应机制、图形渲染处理、音频播放控制等。 在"飞机大战"这一具体游戏实例中,开发者可能运用了以下核心知识点:1. **Pygame基础操作**:掌握如何初始化Pygame环境,设定窗口显示尺寸,加载图像和音频资源,以及如何启动和结束游戏的主循环流程。 2. **面向对象编程**:游戏中的飞机、子弹、敌人等游戏元素通常通过类的设计来实现,利用实例化机制来生成具体的游戏对象。 每个类都定义了自身的属性(例如位置坐标、移动速度、生命值状态)和方法(比如移动行为、碰撞响应、状态更新)。 3. **事件响应机制**:Pygame能够捕获键盘输入和鼠标操作事件,使得玩家可以通过按键指令来控制飞机的移动和射击行为。 游戏会根据这些事件的发生来实时更新游戏场景状态。 4. **图形显示与刷新**:...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值