[20231017]使用dbms_workload_repository.add_colored_sql之2.txt
[20231017]使用dbms_workload_repository.add_colored_sql之2.txt
--//生產系統有一條語句存在效能問題。
1.環境:
SYS@192.168.100.235:1521/orcl> @ pr
==============================
PORT_STRING : x86_64/Linux 2.4.xx
VERSION : 19.0.0.0.0
BANNER : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
BANNER_FULL : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
BANNER_LEGACY : Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
CON_ID : 0
PL/SQL procedure successfully completed.
2.問題:
SYS@192.168.100.235:1521/orcl> @ ashtop sql_id,module1 1=1 &day
Total Distinct Distinct
Seconds AAS %This SQL_ID MODULE1 FIRST_SEEN LAST_SEEN Execs Seen Tstamps
--------- ------- ------- ------------- -------------------- ------------------- ------------------- ---------- --------
13275 .2 15% | 2023-10-09 11:13:29 2023-10-10 11:13:26 1 9935
11624 .1 13% | backup incr datafile 2023-10-09 23:19:33 2023-10-10 00:14:01 1 3260
10858 .1 12% | w3wp.exe 2023-10-09 11:13:29 2023-10-10 11:13:22 6 7621
7246 .1 8% | 675pg97p5artg w3wp.exe 2023-10-09 11:13:29 2023-10-10 09:33:52 4 3624
5977 .1 7% | jdbc thin client 2023-10-09 11:17:57 2023-10-10 11:04:31 1 5977
5376 .1 6% | 63f20n958qv99 w3wp.exe 2023-10-09 11:18:56 2023-10-10 11:08:43 4296 2888
3480 .0 4% | cyqv7gknyf7bh w3wp.exe 2023-10-10 01:00:03 2023-10-10 04:26:51 2307 3480
923 .0 1% | g1v8dts358gq5 w3wp.exe 2023-10-09 11:21:51 2023-10-10 11:13:23 259 780
....
30 rows selected.
--//sql_id=675pg97p5artg,一天的時間內僅僅執行4次.每次7246/4 = 1811.5,差不多每次30分鐘。
--//建立索引最佳化後,我想觀察最佳化效果,發現awr不再記錄該語句執行情況。平時執行太少,我查詢v$sqlarea也沒有結果,
--//也就是該語句根本不在共享池裡面。
--//為了記錄該語句的執行情況想到了dbms_workload_repository.add_colored_sql。
SYS@192.168.100.235:1521/orcl> exec dbms_workload_repository.add_colored_sql('675pg97p5artg');
PL/SQL procedure successfully completed.
SYS@192.168.100.235:1521/orcl> select * from DBA_HIST_COLORED_SQL ;
DBID SQL_ID CREATE_TIME CON_ID
---------- ------------- ------------------- ----------
1585360079 675pg97p5artg 2023-10-18 08:33:50 0
SYS@192.168.100.235:1521/orcl> column owner format 99999999
SYS@192.168.100.235:1521/orcl> select * from sys.wrm$_colored_sql;
DBID SQL_ID OWNER CREATE_TIME
---------- ------------- --------- -------------------
1585360079 675pg97p5artg 1 2023-10-18 08:33:50
1 row selected.
--//我有一種感覺執行次數太少,也許在一個小時之內已經不再共享池,有可能抓取不到相關執行資訊。還是等待一定的時間觀察看看。
3.等待時間觀察。
SYS@192.168.100.235:1521/orcl> @ sqlhh 675pg97p5artg 5
time unit : millisecond
BEGIN_INTERVAL_TIME INST_ID SQL_ID PLAN_HASH_VALUE EXECUTIONS ELA_MS_PER_EXEC CPU_MS_PER_EXEC ROWS_PER_EXEC LIOS_PER_EXEC BLKRD_PER_EXEC IOW_MS_PER_EXEC AVG_IOW_MS CLW_MS_PER_EXEC APW_MS_PER_EXEC CCW_MS_PER_EXEC
------------------- ---------- ------------- --------------- ---------- --------------- --------------- ------------- ------------- -------------- --------------- ----------- --------------- --------------- ---------------
2023-10-16 11:00:22 1 675pg97p5artg 3495262713 5 76679 1725 0.0 257389 13647 75734 5.5 0 0 3
2023-10-16 12:00:25 1 675pg97p5artg 3495262713 1 6509723 117415 0.0 17008226 617391 6430447 10.4 0 0 1240
2023-10-16 17:00:38 1 675pg97p5artg 3255412359 1 438355 27841 0.0 1549877 1549299 433246 35.7 0 54 0
2023-10-16 17:00:38 1 675pg97p5artg 3495262713 2 6031 2828 0.0 959377 669 3237 4.8 0 0 0
2023-10-18 15:00:39 1 675pg97p5artg 1475918621 3 6 3 0.0 5 0 3 9.4 0 0 0
2023-10-19 10:00:30 1 675pg97p5artg 1475918621 1 9 1 0.0 3 1 8 8.1 0 0 0
6 rows selected.
--//現在選擇的執行計劃很好,返回行數居然是0.
4.收尾:
--//exec dbms_workload_repository.remove_colored_sql('675pg97p5artg');
--//select * from sys.wrm$_colored_sql;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2990580/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20231017]使用dbms_xplan.display_awr查詢遇到的問題.txt
- [20220302]oracle如何定位使用library cache mutex 2.txtOracleMutex
- [20200225]觀察使用TCP keep-alive feature特性2.txtTCPKeep-Alive
- [20221028]rman使用tape與增量備份測試2.txt
- [20200213]使用DBMS_SHARED_POOL.MARKHOT標識熱物件2.txt物件
- [20191204]關於oracle例項是否使用hugepages問題2.txtOracle
- [20200211]使用DBMS_SHARED_POOL.MARKHOT與sql語句2.txtSQL
- [20220412]shared pool latch與使用sga heap的疑問2.txt
- [20180625]oradebug peek 2.txt
- [20191011]拆分rowid 2.txt
- [20200212]使用DBMS_SHARED_POOL.MARKHOT與sql的計算2.txtSQL
- [20201126]使用cursor_sharing_exact與給sql打補丁2.txtSQL
- [20181113]Logical Standby建立2.txt
- [20231027]Index ITL Limit 2.txtIndexMIT
- [20190102]塊內重整2.txt
- [20220322]探究oracle sequence 2.txtOracle
- [20210828]如何實現2.txt
- [20210223]bbed itl ktbitflg 2.txt
- [20241105]跟蹤library cache lock library cache pin使用gdb(11g)2.txt
- [20180705]關於hash join 2.txt
- [20231025]跟蹤rename操作2.txt
- [20191209]降序索引疑問2.txt索引
- [20190826]update結果集2.txt
- [20190720]sqlplus 與輸出& 2.txtSQL
- [20190419]shared latch spin count 2.txt
- [20220531]inactive session等待事件2.txtSession事件
- [20210507]dump library_cache 2.txt
- [20190116]詭異的問題2.txt
- [20231115]建立enable novalidate約束2.txt
- [20230427]bbed sum apply問題2.txtAPP
- [20191125]oracel SQL parsing function qcplgte 2.txtSQLFunction
- [20191126]探究等待事件的本源2.txt事件
- [20200305]netstat state=ESTABLISHED and timer=probe 2.txt
- [20191119]探究ipcs命令輸出2.txt
- [20191128]oracle Audit檔案管理2.txtOracle
- [20200316]dmesg與時間戳2.txt時間戳
- [20200718]注意sql hint寫法2.txtSQL
- [20230108]ORA-00600 and Session Disconnected 2.txtSession