SP2-0618 0611錯誤解決辦法
SQL調優佔到了全部調優工作的90%以上,所以很多大牛做調優都是在SQL上進行最佳化。在生產庫上,可能巢狀兩層、三層甚至多層迴圈,進行不同的表連線,而執行計劃恰好能夠反映Oracle執行該SQL語句的流程,所以檢視執行計劃是很有幫助的。
但是對於初次檢視執行計劃的使用者需要一個plustrace角色,否則就會報下面的錯:
scott@PROD>set autotrace traceonly
SP2-0618: Cannot find the Session Identifier. Check PLUSTRACE role is enabled
SP2-0611: Error enabling STATISTICS report
SP2-0618: 無法找到會話識別符號。啟用檢查 PLUSTRACE 角色
解決辦法如下:
一、跑指令碼plustrce.sql
指令碼內容如下,很簡單,就是建立plustrace角色:
[oracle@RH55_11g ~]$cat $ORACLE_HOME/sqlplus/admin/plustrce.sql set echo on
drop role plustrace; create role plustrace;
grant select on v_$sesstat to plustrace; grant select on v_$statname to plustrace; grant select on v_$mystat to plustrace; grant plustrace to dba with admin option;
set echo off |
先跑指令碼來建立角色:
sys@PROD>@?/sqlplus/admin/plustrce.sql sys@PROD> set echo on sys@PROD> sys@PROD>drop role plustrace;
Role dropped.
sys@PROD>create role plustrace;
Role created.
sys@PROD> sys@PROD>grant select on v_$sesstat to plustrace;
Grant succeeded.
sys@PROD>grant select on v_$statname to plustrace;
Grant succeeded.
sys@PROD>grant select on v_$mystat to plustrace;
Grant succeeded.
sys@PROD>grant plustrace to dba with admin option;
Grant succeeded.
sys@PROD> sys@PROD>set echo off |
二、授予該使用者plustrace角色
sys@PROD>grant plustrace to scott;
Grant succeeded. |
三、在scott使用者下開啟跟蹤,檢視執行計劃
sys@PROD>conn scott/tiger Connected. scott@PROD>set autotrace traceonly scott@PROD>select * from emp;
14 rows selected.
Execution Plan ---------------------------------------------------------- Plan hash value: 3956160932
-------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 14 | 532 | 3 (0)| 00:00:01 | | 1 | TABLE ACCESS FULL| EMP | 14 | 532 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------
Statistics ---------------------------------------------------------- 37 recursive calls 0 db block gets 71 consistent gets 6 physical reads 0 redo size 1630 bytes sent via SQL*Net to client 523 bytes received via SQL*Net from client 2 SQL*Net roundtrips to/from client 6 sorts (memory) 0 sorts (disk) 14 rows processed
scott@PROD> |
還有另一種檢視執行計劃,可以不需要plustrace角色,透過呼叫dbms_xplan.display來檢視執行計劃:
scott@PROD>conn / as sysdba Connected. sys@PROD>drop role plustrace;
Role dropped.
Elapsed: 00:00:00.12 sys@PROD>conn scott/tiger Connected. scott@PROD>explain plan for 2 select * from dept;
Explained.
Elapsed: 00:00:00.01 scott@PROD>select * from table(dbms_xplan.display);
PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Plan hash value: 3383998547
-------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | -------------------------------------------------------------------------- | 0 | SELECT STATEMENT | | 4 | 80 | 3 (0)| 00:00:01 | | 1 | TABLE ACCESS FULL| DEPT | 4 | 80 | 3 (0)| 00:00:01 | --------------------------------------------------------------------------
8 rows selected. |
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12707874/viewspace-2125855/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAP錯誤提示解決辦法
- dns錯誤怎麼辦 dns錯誤的解決辦法DNS
- 連線oracle錯誤解決辦法Oracle
- nginxFastCGI錯誤Primaryscriptunknown解決辦法NginxAST
- Unable to locate package錯誤解決辦法Package
- oracle 1455 錯誤解決辦法Oracle
- 畢設之錯誤解決辦法
- SP2-0618和_SP2-0611錯誤處理
- 錯誤SP2-0618和SP2-0611處理
- Idea編譯錯誤解決辦法Idea編譯
- PHP編譯錯誤及解決辦法PHP編譯
- scp出現錯誤的解決辦法
- samba一個錯誤的解決辦法!Samba
- ORA-29339錯誤解決辦法
- ORA-54013錯誤解決辦法
- SP2-0618和_SP2-0611錯誤處理(轉)
- iOS路上遇到的錯誤及解決辦法iOS
- ubuntu下import matplotlib錯誤解決辦法UbuntuImport
- ORA-12705,錯誤的解決辦法
- OpenCV1.0編譯錯誤解決辦法OpenCV編譯
- Xamarin提示安裝包錯誤解決辦法
- ORA-32004錯誤解決辦法
- SPFILE引數修改錯誤的解決辦法
- ORA-12170錯誤的解決辦法
- ORA-01846錯誤解決辦法
- Mysql出現連線錯誤解決辦法MySql
- ORA-39006錯誤原因及解決辦法
- Git 錯誤:fatel: loose object ... is corrupt 解決辦法GitObject
- 開機checking file錯誤的解決辦法
- Python——Output not utf-8錯誤解決辦法Python
- This function has none of DETEMINISTIC,NO SQL錯誤解決辦法FunctionNoneSQL
- VPN連線800錯誤的解決辦法(轉)
- CentOS 中yum命令執行錯誤解決辦法CentOS
- Myeclipse 錯誤An internal error has occurred 解決辦法EclipseError
- nginx FastCGI錯誤Primary script unknown解決辦法NginxAST
- ORA-16014錯誤解決辦法
- Django Admin 錄入中文錯誤解決辦法Django
- ORA-02095錯誤解決辦法