Quantcast
Channel: PeopleSoft Wiki - new forum posts
Viewing all articles
Browse latest Browse all 375

Quick stats update on oracle database

$
0
0

SET echo ON;
SET serveroutput ON;
DECLARE
BEGIN
FOR i IN
(SELECT DISTINCT TABLE_NAME,
num_rows
FROM all_tables c
WHERE TABLE_NAME IN
(SELECT table_name
FROM dba_TAB_STATISTICS
WHERE STALE_STATS='YES'
AND owner ='FSUSER'
—and num_rows between 100000 and 500000
)
)
LOOP
dbms_output.put_line(TO_CHAR(sysdate,'dd-mon-yyyy:hh24:mi:ss')||' start '|| i.table_name);
IF i.num_rows <5000000 then
dbms_stats.gather_table_stats('FSUSER',i.table_name);
END IF ;
dbms_stats.gather_table_stats('FSUSER',i.table_name,estimate_percent => dbms_stats.auto_sample_size,degree => 32,METHOD_OPT =>'FOR ALL INDEXED COLUMNS SIZE 1');
dbms_output.put_line(TO_CHAR(sysdate,'dd-mon-yyyy:hh24:mi:ss')||' end '|| i.table_name);
COMMIT;
END LOOP;
END;
/


Forum category: Forum / Hints, Tips & Gotchas
Forum thread: Quick stats update on oracle database

Viewing all articles
Browse latest Browse all 375

Latest Images

Trending Articles



Latest Images