Na DBA_OPTSTAT_OPERATIONS é mantido um histórico de todas as operações executadas utilizando a DBMS_STATS, logo, é possível identificar o inicio e fim de varias operações como:
- gather_table_stats;
- lock_schema_stats;
- gather_fixed_objects_stats;
- gather_system_stats;
- gather_schema_stats;
- gather_dictionary_stats;
- set_system_stats;
- delete_table_stats;
- entre outros.
select operation,
target,
to_char(start_time, 'dd/mm/yyyy hh24:mi:ss') start_time,
to_char(end_time, 'dd/mm/yyyy hh24:mi:ss') end_time
from DBA_OPTSTAT_OPERATIONS
where operation = 'gather_system_stats';
OPERATION TARGET START_TIME END_TIME
------------------------------ ------------------------------ ------------------- -------------------
gather_system_stats 16/10/2017 14:17:21 16/10/2017 14:17:21
gather_system_stats 16/10/2017 14:24:13 16/10/2017 14:24:14
select operation,
target,
to_char(start_time, 'dd/mm/yyyy hh24:mi:ss') start_time,
to_char(end_time, 'dd/mm/yyyy hh24:mi:ss') end_time
from DBA_OPTSTAT_OPERATIONS
where operation = 'gather_schema_stats';
OPERATION TARGET START_TIME END_TIME
------------------------------ ------------------------------ ------------------- -------------------
gather_schema_stats SCHEMA1 19/10/2017 00:02:05 19/10/2017 00:22:28
gather_schema_stats SCHEMA2 19/10/2017 00:22:28 19/10/2017 00:22:28
gather_schema_stats SCHEMA3 19/10/2017 00:22:28 19/10/2017 00:22:28
gather_schema_stats SCHEMA4 19/10/2017 00:22:28 19/10/2017 00:22:28
gather_schema_stats SCHEMA5 19/10/2017 00:22:34 19/10/2017 00:23:02
select operation,
target,
to_char(start_time, 'dd/mm/yyyy hh24:mi:ss') start_time,
to_char(end_time, 'dd/mm/yyyy hh24:mi:ss') end_time
from DBA_OPTSTAT_OPERATIONS
where operation = 'gather_table_stats' and target like '%TABLE1%';
OPERATION TARGET START_TIME END_TIME
------------------------------ ------------------------------ ------------------- -------------------
gather_table_stats SCHEMA1.TABLE1 24/09/2017 07:36:07 24/09/2017 08:13:19
gather_table_stats SCHEMA1.TABLE1 01/10/2017 06:53:58 01/10/2017 07:28:15
gather_table_stats SCHEMA1.TABLE1 08/10/2017 07:06:55 08/10/2017 07:41:41
--Identificando o tempo de retenção (em dias):
select dbms_stats.get_stats_history_retention from dual;
GET_STATS_HISTORY_RETENTION
---------------------------
31
--Alterando a retenção para para mais ou menos dias:
exec dbms_stats.alter_stats_history_retention(10);
PL/SQL procedure successfully completed.
select dbms_stats.get_stats_history_retention from dual;
GET_STATS_HISTORY_RETENTION
---------------------------
10


0 comentários:
Postar um comentário