[20211221]分析sql語句遇到的問題.txt
[20211221]分析sql語句遇到的問題.txt
--//昨天在跟蹤sql語句時遇到的問題,在測試環境做一個記錄。
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
2.測試:
SCOTT@book> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---------- ---------- ------------------------ --------- ------ ------- ---------- --------------------------------------------------
30 4817 38137 DEDICATED 38138 26 182 alter system kill session '30,4817' immediate;
@ 10046on 12
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
@ 10046off
SCOTT@book> @ti
New tracefile_identifier = /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_0001.trc
@ 10046on 12
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
select * from dept where deptno=10;
@ 10046off
3.問題:
--//開啟跟蹤檔案/u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_0001.trc:
$ grep sql_id /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_0001.trc
$ extractsql.sh /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_0001.trc
--//我當時納悶,為什麼跟蹤檔案裡面無法抽取sql語句。檢視第一個跟蹤檔案,馬上發現問題:
$ extractsql.sh /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138.trc
select col#, grantee#, privilege#,max(mod(nvl(option$,0),2)) from objauth$ where obj#=:1 and col# is not null group by privilege#, col#, grantee# order by col#, grantee#
select grantee#,privilege#,nvl(col#,0),max(mod(nvl(option$,0),2))from objauth$ where obj#=:1 group by grantee#,privilege#,nvl(col#,0) order by grantee#
select con#,obj#,rcon#,enabled,nvl(defer,0),spare2,spare3 from cdef$ where robj#=:1
select con#,type#,condlength,intcols,robj#,rcon#,match#,refact,nvl(enabled,0),rowid,cols,nvl(defer,0),mtime,nvl(spare1,0),spare2,spare3 from cdef$ where obj#=:1
select intcol#,nvl(pos#,0),col#,nvl(spare1,0) from ccol$ where con#=:1
select * from dept where deptno=10
select * from dept where deptno=10
select * from dept where deptno=10
alter session set events '10046 trace name context off'
--//僅僅看見3次select * from dept where deptno=10,也就是在第3次後該語句是軟軟解析,以後在跟蹤執行計劃不變沒有重分析的情
--//況下,都是軟軟解析,跟蹤檔案就無法看到執行語句了。
--//問題的本質是我在同一個會話裡面跟蹤2次,並且修改跟蹤檔名,我當時就是遇到這樣的情況.
--//如果使用第2個跟蹤檔案執行
$tkprof /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_001.trc
output = aa
TKPROF: Release 11.2.0.4.0 - Development on Wed Dec 22 09:42:26 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
$ cat aa.prf
TKPROF: Release 11.2.0.4.0 - Development on Wed Dec 22 09:40:25 2021
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Trace file: /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_0001.trc
Sort options: default
********************************************************************************
count = number of times OCI procedure was executed
cpu = cpu time in seconds executing
elapsed = elapsed time in seconds executing
disk = number of physical reads of buffers from disk
query = number of buffers gotten for consistent read
current = number of buffers gotten in current mode (usually for update)
rows = number of rows processed by the fetch or execute call
********************************************************************************
Trace file: /u01/app/oracle/diag/rdbms/book/book/trace/book_ora_38138_0001.trc
Trace file compatibility: 11.1.0.7
Sort options: default
1 session in tracefile.
0 user SQL statements in trace file.
0 internal SQL statements in trace file.
0 SQL statements in trace file.
0 unique SQL statements in trace file.
96 lines in trace file.
7 elapsed seconds in trace file.
4. 附上extractsql.sh指令碼:
$ cat extractsql.sh
#! /bin/bash
awk '/PARSING IN CURSOR/,/END OF STMT/' $1 | egrep -v '^PARSING|^END OF STMT'
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2848773/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20230329]記錄除錯sql語句遇到的問題.txt除錯SQL
- jivejdon sql語句問題SQL
- [20130628]sql語句顯示不全的問題.txtSQL
- 對sql語句的優化問題SQL優化
- [20150705]從AWR抽取有問題的sql語句.txtSQL
- 對sql語句的最佳化問題SQL
- [20170703]SQL語句分析執行過程.txtSQL
- SQL語句巢狀查詢問題SQL巢狀
- oracle效能問題:sql語句優化OracleSQL優化
- sql語句的優化分析SQL優化
- 關於sql語句的遊標共享問題SQL
- 一個JTextPane寫SQL語句的問題SQL
- [20211229]toad下優化sql語句注意的問題.txt優化SQL
- 一條sql語句導致的資料庫當機問題及分析SQL資料庫
- 一條sql語句“導致”的資料庫當機問題及分析SQL資料庫
- 50個SQL語句(MySQL版) 問題十四MySql
- SQL 語句select top 變數問題SQL變數
- 通過分析SQL語句的執行計劃優化SQL語句SQL優化
- EditPlus不能著色顯示SQl語句的問題SQL
- 一個使用SQL語句解決的小問題SQL
- sql語句的優化案例分析SQL優化
- [20150611]優化sql遇到問題.txt優化SQL
- [20201105]再分析sql語句.txtSQL
- [20211229]sql語句包含中文儲存clob的編碼問題.txtSQL
- [20120229]無效sql語句與shared pool的問題.txtSQL
- 多語言遇到的問題
- [20150403]修正sql語句.txtSQL
- 生產SQL語句突然變慢問題定位SQL
- SQL查詢語句臃腫問題淺析SQL
- [20211221]記錄使用sqlplus的小問題補充.txtSQL
- 使用sql語句分析雙色球SQL
- 透過sql語句分析足彩SQL
- 通過sql語句分析足彩SQL
- 用EXPLAIN PLAN 分析SQL語句AISQL
- 從SQL Server匯出txt檔案匯入Oralce遇到毫秒問題SQLServer
- [20210923]sql語句佔用Sharable Memory分析.txtSQL
- [20181119]sql語句執行緩慢分析.txtSQL
- 執行SQL語句遇到3113錯誤SQL