oracle高水位怎么看 oracle高水位是什么意思

如何看懂ORACLE执行计划一、什么是执行计划
An explain plan is a representation of the access path that is taken when a query is executed within Oracle.
二、如何访问数据
At the physical level Oracle reads blocks of data. The smallest amount of data read is a single Oracle block, the largest is constrained by operating system limits (and multiblock i/o). Logically Oracle finds the data to read by using the following methods:
Full Table Scan (FTS)--全表扫描
Index Lookup (uniquenon-unique)--索引扫描(唯一和非唯一)
Rowid--物理行id
三、执行计划层次关系
When looking at a plan, the rightmost (ie most inndented) uppermost operation is the first thing that is executed. --采用最右最上最先执行的原则看层次关系,在同一级如果某个动作没有子ID就最先执行
1.一个简单的例子:
SQL select/* parallel (e 4)*/*fromempe;
Execution Plan
----------------------------------------------------------
0SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=82 Bytes=7134)
10TABLE ACCESS* (FULL) OF 'EMP' (Cost=1 Card=82 Bytes=7134):Q5000
--[:Q5000]表示是并行方式
1 PARALLEL_TO_SERIALSELECT /*NO_EXPAND ROWID(A1) */ A1."EMPNO"
,A1."ENAME",A1."JOB",A1."MGR",A1."HI
优化模式是CHOOSE的情况下,看Cost参数是否有值来决定采用CBO还是RBO:
SELECT STATEMENT [CHOOSE] Cost=1234--Cost有值 , 采用CBO
SELECT STATEMENT [CHOOSE]--Cost为空,采用RBO(9I是如此显示的)
2.层次的父子关系的例子:
PARENT1
**FIRST CHILD
****FIRST GRANDCHILD
**SECOND CHILD
Here the same principles apply, the FIRST GRANDCHILD is the initial operation then the FIRST CHILD followed by the SECOND CHILD and finally the PARENT collates the output.
四、例子解说
Execution Plan
----------------------------------------------------------
0 **SELECT STATEMENT Optimizer=CHOOSE (Cost=3 Card=8 Bytes=248)
1 0 **HASH JOIN (Cost=3 Card=8 Bytes=248)
2 1 ****TABLE ACCESS (FULL) OF 'DEPT' (Cost=1 Card=3 Bytes=36)
3 1 ****TABLE ACCESS (FULL) OF 'EMP' (Cost=1 Card=16 Bytes=304)
左侧的两排数据,前面的是序列号ID , 后面的是对应的PID(父ID) 。
A shortened summary of this is:
Execution starts with ID=0: SELECT STATEMENT but this is dependand on it's child objects
So it executes its first child step: ID=1 PID=0 HASH JOIN but this is dependand on it's child objects
So it executes its first child step: ID=2 PID=1 TABLE ACCESS (FULL) OF 'DEPT'
Then the second child step: ID=3 PID=2 TABLE ACCESS (FULL) OF 'EMP'
Rows are returned to the parent step(s) until finished
五、表访问方式
1.Full Table Scan (FTS) 全表扫描
In a FTS operation, the whole table is read up to the high water mark (HWM). The HWM marks the last block in the table that has ever had data written to it. If you have deleted all the rows then you will still read up to the HWM. Truncate resets the HWM back to the start of the table. FTS uses multiblock i/o to read the blocks from disk.--全表扫描模式下会读数据到表的高水位线(HWM即表示表曾经扩展的最后一个数据块),读取速度依赖于Oracle初始化参数db_block_multiblock_read_count(我觉得应该这样翻译:FTS扫描会使表使用上升到高水位(HWM),HWM标识了表最后写入数据的块,如果你用DELETE删除了所有的数据表仍然处于高水位(HWM),只有用TRUNCATE才能使表回归,FTS使用多IO从磁盘读取数据块).
Query Plan
【oracle高水位怎么看 oracle高水位是什么意思】------------------------------------
SELECT STATEMENT [CHOOSE] Cost=1
**INDEX UNIQUE SCAN EMP_I1--如果索引里就找到了所要的数据 , 就不会再去访问表
2.Index Lookup 索引扫描
There are 5 methods of index lookup:
index unique scan--索引唯一扫描
Method for looking up a single key value via a unique index. always returns a single value, You must supply AT LEAST the leading column of the index to access data via the index.
eg:SQL explain plan for select empno,ename from emp where empno=10;
index range scan--索引局部扫描
Index range scan is a method for accessing a range values of a particular column. AT LEAST the leading column of the index must be supplied to access data via the index. Can be used for range operations (e.g.= = between) .
eg:SQL explain plan for select mgr from emp where mgr = 5;
index full scan--索引全局扫描
Full index scans are only available in the CBO as otherwise we are unable to determine whether a full scan would be a good idea or not. We choose an index Full Scan when we have statistics that indicate that it is going to be more efficient than a Full table scan and a sort. For example we may do a Full index scan when we do an unbounded scan of an index and want the data to be ordered in the index order.
eg: SQL explain plan for select empno,ename from big_emp order by empno,ename;
index fast full scan--索引快速全局扫描,不带order by情况下常发生
Scans all the block in the index, Rows are not returned in sorted order, Introduced in 7.3 and requires V733_PLANS_ENABLED=TRUE and CBO, may be hinted using INDEX_FFS hint, uses multiblock i/o, can be executed in parallel, can be used to access second column of concatenated indexes. This is because we are selecting all of the index.
eg: SQL explain plan for select empno,ename from big_emp;
index skip scan--索引跳跃扫描,where条件列是非索引的前导列情况下常发生
Index skip scan finds rows even if the column is not the leading column of a concatenated index. It skips the first column(s) during the search.
eg:SQL create index i_emp on emp(empno, ename);
SQL select /*index_ss(emp i_emp)*/ job from emp where ename='SMITH';
3.Rowid 物理ID扫描
This is the quickest access method available.Oracle retrieves the specified block and extracts the rows it is interested in. --Rowid扫描是最快的访问数据方式
oracle设置水位线有什么作用,或者说有什么好处?请给解释一下,谢谢了 。高水位线的意思是oracle数据块历史使用空间的最高点,好处就是比如做全表扫描的话 , 有了高水位线 , 全表扫描只会扫描到水位线处,再向上就不会扫描了,因为根本没有数据,所以对oracle查询性能是有一定的帮助的,另外如果一个表做过大量的delete操作的话 , 需要定时shrink,因为delete不回收高水位,下次做全表扫描的时候还会扫描到高水位线,但其实高水位以下很多都是free的空间 , 会影响全表扫描的性能 , 这也是如果你想删除表中所有数据时最好用truncate的原因,因为truncate回收高水位 。
很精辟的oracle高水位线,终于知道DELETE和TRUNCATE为什么不一样两个操作都是删除表数据的但是实际却又很大的不同
delete只是单纯的删掉表里的数据,他可以添加删除条件,但是不会将空间回收,删除的时候有记录日志,方便恢复,但是速度比较慢
truncate table是全表清空的操作,回收空间,无日志,基本上是不可恢复的
Oracle里面 表的高水位是怎么会事情? 就是说的HWM哪个东西在MSSM的FREELIST下, 高水位High Water Mark代表所有相关块,高水位以上就是未格式化unformatted 的数据块 , INSRT数据时不能直接使用 。当FREELIST中不包含可插入数据块时 HWM默认每次上升5个数据块 。
对于ASSM管理的BITMAP 数据段而言,Oracle允许在数据段的中部出现unformatted blocks未格式化的数据块 , 基于以下的原因:
一、在以前 HWM以下的数据块必然是formatted,为了维护这一点代价是昂贵的:
长时间持有HW enqueue队列锁对并发的抑制
过于频繁的持有HW enqueue在Oracle研发看来是罪恶的
上涨HWM 而不格式化 这样的话更有效率,因为格式化往往涉及到 IO,是一种较慢的操作
二、 在直接路径加载过程中,最后的一个extent中的数据块将被全部format 格式化,而如果下一次还是direct load直接路径加载数据的话,它不会从Freelist上获取数据块 , 而是使用HWM以上新的数据盘区extent 。如果这个数据段是典型的一直在direct load加载数据的话 , 则可能在freelist上有很多unused block从来不被使用,而被浪费了 。这可能造成空间的浪费,尤其是在Extent size 很大的时候 或者 数据段几乎从来不传统路径插入数据的时候 。保留这些数据块为unformatted则可以让加载数据时利用到这些空间空洞
如果自己搞不定可以找ASKMACLEAN专业ORACLE数据库修复团队成员帮您恢复!
oracle 如何查看表 高水位线select blocks, empty_blocks from dba_tables where table_name='xxx' and owner='xx';
blocks就是已经分配oracle高水位怎么看的空间即HWMoracle高水位怎么看,实际分配oracle高水位怎么看的空间oracle高水位怎么看 , 不是实际大小
如何降低Oracle表的高水位1. 执行表重建指令 alter table table_name move(验证不可行oracle高水位怎么看 , 不降低水位线oracle高水位怎么看,但可释放表空间)
当你创建了一个对象如表以后,不管你有没有插入数据,它都会占用一些块,ORACLE也会给它分配必要的空间.同样,用ALTER TABLE MOVE释放自由空间后,还是保留了一些空间给这个表.
ALTER TABLE ... MOVE 后面不跟参数也行,不跟参数表还是在原来的表空间 , Move后记住重建索引.
查询失效索引语句oracle高水位怎么看:select index_name,table_name,tablespace_name,status From dba_indexes Where owner='HNUNICOM' And status'VALID';
重建索引语句:alter index INDEX_NAME rebuild tablespace TABLESPACE_NAME;
如果以后还要继续向这个表增加数据,没有必要move , 只是释放出来的空间,只能这个表用,其oracle高水位怎么看他的表或者segment无法使用该空间 。
2. 执行alter table table_name shrink space;(已经验证成功 , 推荐使用,可释放数据库和磁盘空间空间,大表可同时降低表自身和表空间的高水位线,小表则只可以降低表自身的高水位线 , 原因不详)
注意,此命令为Oracle 10g新增功能,执行该指令之前必须允许行移动 alter table table_name enable row movement;
3. 复制要保留的数据到临时表t,drop原表 , 然后rename临时表t为原表(未验证
4. 用EXP导出后,删除原表/表空间,之后用IMP重新导入(验证成功)
5. Alter table table_name deallocate unused(验证不可行 , 不降低水位线)
注:这证明,DEALLOCATE UNUSED为释放HWM上面的未使用空间,但是并不会释放HWM下面的自由空间,也不会移动HWM的位置.
6. 尽量使用truncate(验证不可行 , 不降低水位线,可释放数据库空间,但truncate后表默认空间大小为删除前的空间大小 , 如想释放计算机磁盘空间,需要用方法2压缩)
oracle高水位怎么看的介绍就聊到这里吧,感谢你花时间阅读本站内容 , 更多关于oracle高水位是什么意思、oracle高水位怎么看的信息别忘了在本站进行查找喔 。

    推荐阅读