您的位置:首页 > 移动开发 > Objective-C

41.You have recently collected statistics on certain objects of a schema in your database. But you o

2016-07-21 16:54 781 查看
41.You have recently collected statistics on certain objects of a schema in your database. But you

observe suboptimal execution plans for the queries on these objects after two days of statistics collection.

The optimizer statistics retention period is set to its default value.

Which action would help to use the previous set of statistics on the objects?

A.Restore statistics from statistics history.

B.Reduce the optimizer statistics retention period by 2 days.

C.Set the OPTIMIZER_PENDING_STATISTICS parameter to TRUE.

D.Reduce the Automatic Workload Repository (AWR) retention period by 2 days.

答案:A

解析:题目说的是,优化器收集统计信息的周期为默认值,最近你在一个schema的object上收集了统计信息,但是发现

对于查询的执行计划不如之前的不太好,你应该怎么做

A:从统计信息历史记录中restore

B:减少统计信息的保留时间

C:设置OPTIMIZER_PENDING_STATISTICS为true

D:减少awr的保留时间

从这里可以看出应该选择A,那A是干啥的

SQL> select to_char(stats_update_time,'yyyy-mm-dd hh24:mi:ss') FROM DBA_TAB_STATS_HISTORY where owner = 'SCOTT' and table_name = 'SALES';

TO_CHAR(STATS_UPDAT

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

2016-07-17 09:20:14

2016-07-15 22:00:20

SQL> select to_char(last_analyzed,'yyyy-mm-dd hh24:mi:ss') from dba_tables where table_name = 'SALES' and owner = 'SCOTT';

TO_CHAR(LAST_ANALYZ

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

2016-07-17 09:20:14

SQL> exec dbms_stats.restore_table_stats('SCOTT', 'SALES', TO_DATE('2016-07-15 22:00:20', 'yyyy-mm-dd hh24:mi:ss'));

PL/SQL procedure successfully completed.

SQL> select to_char(last_analyzed,'yyyy-mm-dd hh24:mi:ss') from dba_tables where table_name = 'SALES' and owner = 'SCOTT';

TO_CHAR(LAST_ANALYZ

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

--查看统计信息保存的时间

select DBMS_STATS.GET_STATS_HISTORY_RETENTION from dual; 

--这里为啥没有恢复回去

SQL> exec dbms_stats.gather_table_stats('SCOTT', 'SALES', cascade=>true);

PL/SQL procedure successfully completed.

---收集一下信息我们在来一次

SQL> select to_char(last_analyzed,'yyyy-mm-dd hh24:mi:ss') from dba_tables where table_name = 'SALES' and owner = 'SCOTT';

TO_CHAR(LAST_ANALYZ

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

2016-07-17 21:20:59

SQL> select to_char(stats_update_time,'yyyy-mm-dd hh24:mi:ss') FROM DBA_TAB_STATS_HISTORY where owner = 'SCOTT' and table_name = 'SALES';

TO_CHAR(STATS_UPDAT

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

2016-07-17 21:20:59 --这个是gather_table_stats

2016-07-17 09:20:14 --这个是restore_table_stats

2016-07-17 17:51:41

2016-07-15 22:00:20

--再来执行一次

SQL> exec dbms_stats.restore_table_stats('SCOTT', 'SALES', '15-JUL-16 10.00.20.846989 PM +08:00',force=>true);

PL/SQL procedure successfully completed.

SQL> select to_char(last_analyzed,'yyyy-mm-dd hh24:mi:ss') from dba_tables where table_name = 'SALES' and owner = 'SCOTT';

TO_CHAR(LAST_ANALYZ

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

2016-07-17 09:16:33

--但是这里为啥显示的是这个时间就不知道了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  1z0-052
相关文章推荐