Monday, February 19, 2018

GATHER_STATS_JOB job log history




Reference taken from -

history of last run of GATHER_STATS_JOB


col job_name FOR a30
SET lines 150
SELECT * FROM
     (SELECT log_date,job_name,status,actual_start_date,run_duration
     FROM DBA_SCHEDULER_JOB_RUN_DETAILS
     WHERE job_name='GATHER_STATS_JOB'
     ORDER BY log_id DESC)
     WHERE rownum<=2;

Another Script

SET lines 150 col OPERATION FOR a30 col TARGET FOR a5 col START_TIME FOR a40 col END_TIME FOR a40 SELECT * FROM dba_optstat_operations ORDER BY start_time DESC
Satistics on a table have changed by using DBA_TAB_STATS_HISTORY table
(job details is unfortunately not available):

 SET lines 180
 SELECT owner, table_name, stats_update_time
     FROM dba_tab_stats_history
     WHERE owner='&OWNER'
     AND table_name='&TABLE NAME'
     ORDER BY owner, table_name, stats_update_time DESC;


With above query I can easily see when statistics have changed.
I can’t know if they have been computed manually or
by GATHER_STATS_JOB but time of the gathering give some clues of
who/what has done it…So to have number of objects per day
which had their statistics changed (including GATHER_STATS_JOB
and manual gathering) you can use

SET lines 150
 SET pages 200
 SELECT TO_CHAR(stats_update_time,'yyyy-mm-dd') AS stats_update_time, COUNT(*)
     FROM dba_tab_stats_history
     GROUP BY TO_CHAR(stats_update_time,'yyyy-mm-dd')
     ORDER BY 1 DESC;

No comments: