当前位置:Gxlcms > 数据库问题 > ORACLE ANALYZE

ORACLE ANALYZE

时间:2021-07-01 10:21:17 帮助过:22人阅读

t T1 using (select 1001 as a, 2 as b from dual) T2 on (T1.a = T2.a) when matched then update set T1.b = T2.b;

所以即使是一张空表,如果对字段进行了增删改,即使merge字段很少时,也需要对表进行analyze。也就是说当前表的查询或其他性能不好时,都可以对相应的表进行一次分析。

 

Analyze概述

 

1. 要是CBO发挥最大的作用,就必须对对象进行分析。Oracle根据结果取cost最小的方案执行SQL。

2. 数据库的分析可以通过analyze对表执行,也可以通过DBMS_DDL、DBMS_UTILITY、DBMS_STATS(没有用过)等包批量分析某个用户或者整个数据库。

3. 命令truncate不会修改数据的统计信息.

4. 可以对数据库的所有表每日特定时间进行分析,特殊情况下才手动analyze。

5. 一般使用①对表进行分析即可.

--① 分析表的所有字段,所有索引,所有索引字段。其中:① = ②
analyze table student compute statistics;  
--② 分析表的所有字段,所有索引,所有索引字段。其中:① = ②
analyze table student compute statistics for table for all indexes for all columns;   
--③ 只分析所有有索引的字段
analyze table student compute statistics for table for all indexes for all indexed columns;  

--④ 抽样估算法
analyze table student estimate statistics sample 20 percent;

--⑤ 删除分析数据
analyze table student delete statistics;
analyze table student delete statistics for table for all indexes for all indexed columns; 

--查看表的统计信息
select table_name,num_rows,blocks,empty_blocks from user_tables where table_name=student;

 

ORACLE ANALYZE

标签:delete   cos   sam   color   table   多次   mat   ora   int   

人气教程排行