您好,登錄后才能下訂單哦!
本篇內容介紹了“oracle數據庫CPU過高問題舉例分析”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
一、環境準備
1、查看當前快照情況
SQL> select max(snap_id) from dba_hist_snapshot s; 28
2、手工生成一份快照
exec dbms_workload_repository.create_snapshot;
3、創建實驗表
SQL> create sequence s_t3_id minvalue 1 maxvalue 9999999999 start with 1 increment by 1 cache 20 order; SQL> create table t3 (id number,name varchar2(20),created date); Table created. SQL> begin 2 for i in 1 .. 5000000 loop 3 insert into t3 values (s_t3_id.Nextval,dbms_random.string('u', 10),sysdate); 4 end loop; 5 end; 6 / SQL> create sequence s_t4_id minvalue 1 maxvalue 9999999999 start with 1 increment by 1 cache 20 order; SQL> create table t4 (id number,name varchar2(20),created date); Table created. SQL> begin 2 for i in 1 .. 3000000 loop 3 insert into t4 values (s_t4_id.Nextval,dbms_random.string('u', 10),sysdate); 4 end loop; 5 end; 6 / SQL> select * from scott.t3 where name=dbms_random.string('u', 10); no rows selected SQL> select * from scott.t4 where name=dbms_random.string('u', 10); no rows selected
4、手工生成快照
exec dbms_workload_repository.create_snapshot;
至此,模擬問題出現時的快照區間為29-30
二、使用SPA進行分析
begin 2 dbms_sqltune.create_sqlset( 3 sqlset_name=>'cpu_test', 4 description => 'High cpu read tuning set'); 5 end; 6 / PL/SQL procedure successfully completed. SQL> declare 2 base_cur dbms_sqltune.sqlset_cursor; 3 begin 4 open base_cur for 5 select value(x) from table(DBMS_SQLTUNE.select_workload_repository(29,30,NULL,NULL,'cpu_time',NULL,NULL,NULL,10)) x; 6 -- 7 dbms_sqltune.load_sqlset(sqlset_name=>'cpu_test',populate_cursor => base_cur); 8 end; 9 / PL/SQL procedure successfully completed. SQL> variable sts_task VARCHAR2(64); SQL> EXEC :sts_task :=DBMS_SQLPA.CREATE_ANALYSIS_TASK(sqlset_name=>'cpu_test',order_by=>'cpu_time',description=>'process workload ordered by cpu_time'); PL/SQL procedure successfully completed. SQL> EXEC DBMS_SQLPA.execute_analysis_task(task_name=>:sts_task,execution_params=>dbms_advisor.arglist('TIME_LIMIT','1800')); PL/SQL procedure successfully completed. SQL> set serveroutput on SQL> set heading off SQL> set pagesize 2000 SQL> set long 20000 SQL> spool compare_report.html SQL> select DBMS_SQLPA.report_analysis_task(:sts_task,'HTML','ALL','ALL') from dual; SQL> spool off
查看生產的HTML文件,可看到時間范圍內運行的所有sql的信息
“oracle數據庫CPU過高問題舉例分析”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。