Oracle效能調優之--Oracle sql語句跟蹤

來源:互聯網
上載者:User

SQL> showparameter sql

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

plsql_ccflags                        string

plsql_code_type                      string      INTERPRETED

plsql_compiler_flags                 string      INTERPRETED, NON_DEBUG

plsql_debug                          boolean     FALSE

plsql_native_library_dir             string

plsql_native_library_subdir_count    integer    0

plsql_optimize_level                 integer     2

plsql_v2_compatibility               boolean     FALSE

plsql_warnings                       string      DISABLE:ALL

sql92_security                       boolean     FALSE

sql_trace                            boolean     FALSE

sql_version                          string      NATIVE

sqltune_category                     string      DEFAULT

 

SQL>alter  session set    sql_trace=true ;

 

對於跟蹤的sql語句,產生的trace 檔案放在udump 下

 

通過以下語句可以查到產生的trc檔案

 

SQL> selectusername,addr,spid from v$process

  2       where addr=( select paddr from v$session

  3                          where sid=( selectdistinct sid from v$mystat));

 

USERNAME        ADDR    SPID

----------------------- ------------

Oracle          2AE1D48C 13954

 

 

SQL> showparameter dump

 

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

background_core_dump                 string      partial

background_dump_dest                 string      /u01/app/oracle/admin/ora1/bdump                                              

core_dump_dest                       string      /u01/app/oracle/admin/ora1/cdump

max_dump_file_size                   string      UNLIMITED

shadow_core_dump                     string      partial

user_dump_dest                       string      /u01/app/oracle/admin/ora1/udump

                                               

 

[oracle@rac1 ~]$ ls-lth /u01/app/oracle/admin/ora1/udump/

total 156K

-rw-r----- 1 oracleoinstall  87K May 26 17:29 ora1_ora_13954.trc

 

 

用tkprof分析,追蹤檔案

[oracle@rac1 ~]$tkprof

Usage: tkproftracefile outputfile [explain= ] [table= ]

              [print= ] [insert= ] [sys= ][sort= ]

  table=schema.tablename   Use 'schema.tablename' with 'explain='option.

  explain=user/password    Connect to ORACLE and issue EXPLAIN PLAN.

  print=integer    List only the first 'integer' SQLstatements.

  aggregate=yes|no

  insert=filename  List SQL statements and data inside INSERTstatements.

  sys=no           TKPROF does not list SQL statementsrun as user SYS.

  record=filename  Record non-recursive statements found in thetrace file.

  waits=yes|no     Record summary for any wait events foundin the trace file.

  sort=option      Set of zero or more of the following sortoptions:

    prscnt number of times parse was called

    prscpu cpu time parsing

    prsela elapsed time parsing

    prsdsk number of disk reads during parse

    prsqry number of buffers for consistent read during parse

    prscu  number of buffers for current read during parse

    prsmis number of misses in library cache during parse

    execnt number of execute was called

    execpu cpu time spent executing

    exeela elapsed time executing

    exedsk number of disk reads during execute

    exeqry number of buffers for consistent read during execute

    execu  number of buffers for current read during execute

    exerow number of rows processed during execute

    exemis number of library cache misses during execute

    fchcnt number of times fetch was called

    fchcpu cpu time spent fetching

    fchela elapsed time fetching

    fchdsk number of disk reads during fetch

    fchqry number of buffers for consistent read during fetch

    fchcu  number of buffers for current read during fetch

    fchrow number of rows fetched

    userid userid of user that parsed the cursor

更多Oracle相關資訊見Oracle 專題頁面 http://www.bkjia.com/topicnews.aspx?tid=12

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.