Skip to content

Commit f4b3b4f

Browse files
committed
Procedure to gather a users stale statistics and create a scheduled job to run
1 parent b9af27f commit f4b3b4f

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tp_stats.sql

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
REM Script Name : tp_stats.sql
2+
REM Author : Craig Richards
3+
REM Created : 17 January 2013
4+
REM Last Modified :
5+
REM Version : 1.0
6+
REM
7+
REM Modifications :
8+
REM
9+
REM Description :
10+
11+
REM Procedure to gather the statistics, this will be called via the DBMS_SCHEDULER
12+
13+
CREATE OR REPLACE PROCEDURE GATHER_RIMS_STALE_STATISTICS
14+
AS
15+
BEGIN
16+
dbms_stats.gather_schema_stats(ownname=>'RIMS',estimate_percent=>NULL,options=>'GATHER STALE',cascade=>TRUE);
17+
END;
18+
/
19+
20+
REM DBMS_SCHEDULER job to call the procedure
21+
22+
BEGIN
23+
dbms_scheduler.create_job
24+
(job_name=>'GATHER_STALE_RIMS_STATISTICS',
25+
repeat_interval => 'FREQ=DAILY; BYDAY=MON,TUE,WED,THU,FRI; BYHOUR=4; BYMINUTE=00',
26+
job_type=>'stored_procedure',
27+
job_action=>'sys.GATHER_RIMS_STALE_STATISTICS',
28+
enabled=>TRUE,
29+
comments=>'GATHER_RIMS_STALE_STATISTICS');
30+
END;
31+
/

0 commit comments

Comments
 (0)