溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何使用10046查看執(zhí)行計劃并讀懂trace文件

發(fā)布時間:2021-10-26 13:58:57 來源:億速云 閱讀:202 作者:小新 欄目:建站服務(wù)器

這篇文章給大家分享的是有關(guān)如何使用10046查看執(zhí)行計劃并讀懂trace文件的內(nèi)容。小編覺得挺實(shí)用的,因此分享給大家做個參考,一起跟隨小編過來看看吧。

查看 sql 執(zhí)行計劃的方法有許多種, 10046 事件就是其中的一種. 與其他查看 sql 執(zhí)行計劃不同, 當(dāng)我們遇到比較復(fù)雜的 sql 語句, 我們可以通過 10046 跟蹤 sql 得到執(zhí)行計劃中每一個步驟的邏輯讀, 物理讀以及花費(fèi)的時間等. 這種細(xì)粒度的跟蹤對于我們分析 sql 性能尤其有用.

一般來說, 使用 10046 事件得到 sql 執(zhí)行計劃的步驟如下:
1. 激活當(dāng)前 session 10046 事件
2. 在當(dāng)前 session 中執(zhí)行 sql 語句
3. 關(guān)閉當(dāng)前 session 10046 事件

執(zhí)行完上述步驟后, 通常會自動生成一個 trace 文件. 在 oracle 11g 中, trace 文件一般放在$ORACLE_BASE/diag/rdbms/{database_name}/$ORACLE_SID/trace 目錄下. 如果使用 oradebug 激活跟蹤 10046后, 可以使用 oradebug tracefile_name 得到剛剛生成的 trace 文件的完整路徑.

剛剛提到的 oradebug 激活跟蹤 10046 事件, 我想大部分 dba 都會使用. oradebug 是個功能強(qiáng)大非常好用的工具, 使用 oradebug help 將會看到它的功能很多

  1. SQL> oradebug help

  2. HELP           [command]                 Describe one or all commands

  3. SETMYPID                                 Debug current process

  4. SETOSPID       <ospid>                   Set OS pid of process to debug

  5. SETORAPID      <orapid> ['force']         Set Oracle pid of process to debug

  6. SETORAPNAME    <orapname>                 Set Oracle process name to debug

  7. SHORT_STACK                               Get abridged OS stack

  8. CURRENT_SQL                               Get current SQL

  9. DUMP           <dump_name> <lvl> [addr]   Invoke named dump

  10. DUMPSGA        [bytes]                   Dump fixed SGA

  11. DUMPLIST                                 Print a list of available dumps

  12. EVENT          <text>                     Set trace event in process

  13. SESSION_EVENT  <text>                     Set trace event in session

  14. DUMPVAR        <p|s|uga> <name> [level]   Print/dump a fixed PGA/SGA/UGA variable

  15. DUMPTYPE       <address> <type> <count>   Print/dump an address with type info

  16. SETVAR         <p|s|uga> <name> <value>   Modify a fixed PGA/SGA/UGA variable

  17. PEEK           <addr> <len> [level]       Print/Dump memory

  18. POKE           <addr> <len> <value>       Modify memory

  19. WAKEUP         <orapid>                   Wake up Oracle process

  20. SUSPEND                                   Suspend execution

  21. RESUME                                   Resume execution

  22. FLUSH                                     Flush pending writes to trace file

  23. CLOSE_TRACE                               Close trace file

  24. TRACEFILE_NAME                           Get name of trace file

  25. LKDEBUG                                   Invoke global enqueue service debugger

  26. NSDBX                                     Invoke CGS name-service debugger

  27. -G             <Inst-List | def | all>   Parallel oradebug command prefix

  28. -R             <Inst-List | def | all>   Parallel oradebug prefix (return output

  29. SETINST        <instance# .. | all>       Set instance list in double quotes

  30. SGATOFILE      <SGA dump dir>             Dump SGA to file; dirname in double quotes

  31. DMPCOWSGA      <SGA dump dir> Dump & map SGA as COW; dirname in double quotes

  32. MAPCOWSGA      <SGA dump dir>             Map SGA as COW; dirname in double quotes

  33. HANGANALYZE    [level] [syslevel]         Analyze system hang

  34. FFBEGIN                                   Flash Freeze the Instance

  35. FFDEREGISTER                             FF deregister instance from cluster

  36. FFTERMINST                               Call exit and terminate instance

  37. FFRESUMEINST                             Resume the flash frozen instance

  38. FFSTATUS                                 Flash freeze status of instance

  39. SKDSTTPCS      <ifname>  <ofname>         Helps translate PCs to names

  40. WATCH          <address> <len> <self|exist|all|target>  Watch a region of memory

  41. DELETE         <local|global|target> watchpoint <id>    Delete a watchpoint

  42. SHOW           <local|global|target> watchpoints        Show  watchpoints

  43. DIRECT_ACCESS  <set/enable/disable command | select query> Fixed table access

  44. CORE                                     Dump core without crashing process

  45. IPC                                       Dump ipc information

  46. UNLIMIT                                   Unlimit the size of the trace file

  47. PROCSTAT                                 Dump process statistics

  48. CALL           <func> [arg1] ... [argn]   Invoke function with arguments

感謝各位的閱讀!關(guān)于“如何使用10046查看執(zhí)行計劃并讀懂trace文件”這篇文章就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,讓大家可以學(xué)到更多知識,如果覺得文章不錯,可以把它分享出去讓更多的人看到吧!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI