zoukankan      html  css  js  c++  java
  • statspack

    参考视频

    [bbk1269]

    [bbk1270]

    [bbk1271]

    [bbk1272]

    [bbk1279]

    statspack配置文件:sprepcon.sql

    statspack文档:spdoc.txt

    report

    • instance report
      • spreport.sql
      • sprepins.sql(multi-instance)->多个实例时使用
    • sqlp report
      • sprepsql.sql
      • sprsqins.sql(multi-instance)->多个实例时使用

    configure

    • database parameters
    • snapshot parameters
    • instance report parameters
    • sql report prameters

    与statistics相关的数据库参数

    SQL> show parameter statistics
    
    NAME                                 TYPE        VALUE
    ------------------------------------ ----------- ------------------------------
    optimizer_use_pending_statistics     boolean     FALSE
    statistics_level                     string      TYPICAL
    timed_os_statistics                  integer     0
    timed_statistics                     boolean     TRUE
    SQL> 
    View Code

    statistics_level->{ALL | TYPICAL | BASE}

    与snapshot相关的参数

    snapshot level

    • >=0
    • >=5
    • >=6
    • >=7
    • >=10

    snapshot parameter table(在执行snapshot时,如果不输入任何参数,就会读这张表中的参数)

    SQL> desc stats$statspack_parameter;
     Name                                      Null?    Type
     ----------------------------------------- -------- ----------------------------
     DBID                                      NOT NULL NUMBER
     INSTANCE_NUMBER                           NOT NULL NUMBER
     SESSION_ID                                NOT NULL NUMBER
     SNAP_LEVEL                                NOT NULL NUMBER
     NUM_SQL                                   NOT NULL NUMBER
     EXECUTIONS_TH                             NOT NULL NUMBER
     PARSE_CALLS_TH                            NOT NULL NUMBER
     DISK_READS_TH                             NOT NULL NUMBER
     BUFFER_GETS_TH                            NOT NULL NUMBER
     SHARABLE_MEM_TH                           NOT NULL NUMBER
     VERSION_COUNT_TH                          NOT NULL NUMBER
     PIN_STATSPACK                             NOT NULL VARCHAR2(10)
     ALL_INIT                                  NOT NULL VARCHAR2(5)
     LAST_MODIFIED                                      DATE
     UCOMMENT                                           VARCHAR2(160)
     JOB                                                NUMBER
     SEG_PHY_READS_TH                          NOT NULL NUMBER
     SEG_LOG_READS_TH                          NOT NULL NUMBER
     SEG_BUFF_BUSY_TH                          NOT NULL NUMBER
     SEG_ROWLOCK_W_TH                          NOT NULL NUMBER
     SEG_ITL_WAITS_TH                          NOT NULL NUMBER
     SEG_CR_BKS_RC_TH                          NOT NULL NUMBER
     SEG_CU_BKS_RC_TH                          NOT NULL NUMBER
     OLD_SQL_CAPTURE_MTH                       NOT NULL VARCHAR2(10)
    
    SQL> 
    stats$statspack_parameter
    SQL> select snap_level from stats$statspack_parameter;
    
    SNAP_LEVEL
    ----------
             5
    
    SQL> execute statspack.snap(i_snap_level=>7,i_modify_parameter=>'true');
    
    PL/SQL procedure successfully completed.
    
    SQL> select snap_level from stats$statspack_parameter;
    
    SNAP_LEVEL
    ----------
             7
    
    SQL> 
    修改表stats$statspack_parameter中的默认参数值.
    SQL> execute statspack.modify_statspack_parameter(i_snap_level=>6);
    
    PL/SQL procedure successfully completed.
    
    SQL> select snap_level from stats$statspack_parameter;
    
    SNAP_LEVEL
    ----------
             6
    
    SQL> 
    使用包statspack.modify_statspack_parameter修改snapshot_levle为6
    SQL> select count(*) from stats$snapshot;
    
      COUNT(*)
    ----------
             3
    
    SQL> 
    查看采集了多少snapshot
    SQL>execute dbms_job.remove(62);
    PL/SQL procedure successfully completed.
    删除job

    与instance相关的配置参数

    相关的配置文件sprepcon.sql 实际上instance report 与 sql report相关的报表所使用的参数均为sprepcon.sql

    define num_days = '';

    参数解读:假如为'',表示列出所有snapshot;假如设置为10,就表示列出最近10天的snapshot信息. 

    与sql report相关的参数

    相关的配置文件sprepcon.sql

    输出sql report可以根据sql的hash value来生成.

    maintenance

    在众多的snapshot中,那些被有用的,成为baseline.

    purge只会把那些没有标记为baseline的snapshot给删除掉.

    • make_baseline & clear_baseline
    • purge snapshot except baseline
    • truncate all tables with perfstat schema
    • drop perfstat schema
    SQL> select snap_id from stats$snapshot;
    
       SNAP_ID
    ----------
             1
             2
            11
    
    SQL> execute statspack.snap;
    
    PL/SQL procedure successfully completed.
    
    SQL> select snap_id from stats$snapshot;
    
       SNAP_ID
    ----------
             1
             2
            11
            21
    
    SQL> show user
    USER is "PERFSTAT"
    SQL> 
    如何生成statspack报告?
    SQL> show user
    USER is "PERFSTAT"
    SQL> execute statspack.make_baseline(i_begin_snap=>1,i_end_snap=>11);
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    将snap_id为1至11做base_line标记.
    SQL> select snap_id from stats$snapshot;
    
       SNAP_ID
    ----------
             1
             2
            11
            21
    
    SQL> show user
    USER is "PERFSTAT"
    SQL> execute statspack.make_baseline(i_begin_snap=>1,i_end_snap=>11);
    
    PL/SQL procedure successfully completed.
    
    SQL> execute statspack.purge(i_begin_snap=>1,i_end_snap=>21);
    
    PL/SQL procedure successfully completed.
    
    SQL> select snap_id from stats$snapshot;
    
       SNAP_ID
    ----------
             1
             2
            11
    
    SQL> 
    使用statspack.purge进行清除1至21之后,就会将中间没有被标记为baseline的snapshot给清除掉.
    SQL> execute statspack.clear_baseline(i_begin_snap=>1,i_end_snap=>11,i_snap_range=>false);
    
    PL/SQL procedure successfully completed.
    
    SQL> select snap_id from stats$snapshot;
    
       SNAP_ID
    ----------
             1
             2
            11
    
    SQL> execute statspack.purge(i_begin_snap=>1,i_end_snap=>2);
    
    PL/SQL procedure successfully completed.
    
    SQL> select snap_id from stats$snapshot;
    
       SNAP_ID
    ----------
             2
            11
    
    SQL> 
    清除baseline之后,再进行purge

    truncate all tables with perfstat schema

    truncate all tables with perfstat schema使用到的是sptrunc.sql脚本

    11203ora-> sqlplus perfstat/perfstat
    
    SQL*Plus: Release 11.2.0.3.0 Production on Tue Jul 30 10:09:05 2013
    
    Copyright (c) 1982, 2011, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> @?/rdbms/admin/sptrunc.sql
    
    Warning
    ~~~~~~~
    Running sptrunc.sql removes ALL data from Statspack tables.  You may
    wish to export the data before continuing.
    
    
    About to Truncate Statspack Tables
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    If would like to exit WITHOUT truncating the tables, enter any text at the
    begin_or_exit prompt (e.g. 'exit'), otherwise if you would like to begin
    the truncate operation, press <return>
    
    
    Enter value for begin_or_exit: 
    Entered at the 'begin_or_exit' prompt
    
    ... Starting truncate operation
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    Table truncated.
    
    
    2 rows deleted.
    
    
    2 rows deleted.
    
    
    Commit complete.
    
    
    Package altered.
    
    
    ... Truncate operation complete
    
    SQL> 
    执行truncate操作.
    SQL> select * from stats$snapshot;
    
    no rows selected
    
    SQL> 
    stats$snapshot查看数据,已经不存在.

    drop perfstat schema

    SQL> show user
    USER is "SYS"
    SQL> @?/rdbms/admin/spdrop.sql      
    以sys用户登陆,执行@?/rdbms/admin/spdrop.sql语句.
    11203ora-> vi /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/spdusr.lis 
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    "/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/spdusr.lis" 55L, 361C       1,0-1         Top
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    View dropped.
    
    
    Synonym dropped.
    
    
    User dropped.
    
    
    NOTE:
    SPDUSR complete. Please check spdusr.lis for any errors.
    查看drop日志:
    11203ora-> vi /u01/app/oracle/product/11.2.0/db_1/rdbms/admin/spdtab.lis 
    
    Dropping old versions (if any)
    
    Synonym dropped.
    
    
    Sequence dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    "/u01/app/oracle/product/11.2.0/db_1/rdbms/admin/spdtab.lis" 455L, 2800C     1,1           Top
    Dropping old versions (if any)
    
    Synonym dropped.
    
    
    Sequence dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
    
    Synonym dropped.
    
    
    Table dropped.
    
                                                                                                                                                                                                 1,1           Top
    查看drop table日志
    SQL> select username from dba_users order by 1;
    
    USERNAME
    ------------------------------
    ANONYMOUS
    APEX_030200
    APEX_PUBLIC_USER
    APPQOSSYS
    ARCER
    BI
    CTXSYS
    DBSNMP
    DIP
    EXFSYS
    FLOWS_FILES
    
    USERNAME
    ------------------------------
    HR
    IX
    MDDATA
    MDSYS
    MGMT_VIEW
    OE
    OLAPSYS
    ORACLE_OCM
    ORDDATA
    ORDPLUGINS
    ORDSYS
    
    USERNAME
    ------------------------------
    OUTLN
    OWBSYS
    OWBSYS_AUDIT
    PM
    RMAN
    SCOTT
    SH
    SI_INFORMTN_SCHEMA
    SPATIAL_CSW_ADMIN_USR
    SPATIAL_WFS_ADMIN_USR
    SYS
    
    USERNAME
    ------------------------------
    SYSMAN
    SYSTEM
    TEST1
    WMSYS
    XDB
    XS$NULL
    
    39 rows selected.
    
    SQL> 
    校验用户perfstat已经不存在.

    如何导入perfstat用户?

    前提:创建好用户,创建好权限.

    创建用户的话,我们使用oracle提供好的spcusr.sql脚本.但是此脚本需要做修改.

    SQL> create user perfstat identified by perfstat default tablespace ts_perf temporary tablespace temp quota unlimited on ts_perf;
    
    User created.
    
    SQL> 
    创建用户perfstat
    11203ora-> vi temp01.sql 
    
    grant select on V_$THREAD                   to PERFSTAT;
    grant select on V_$CR_BLOCK_SERVER          to PERFSTAT;
    grant select on V_$CURRENT_BLOCK_SERVER     to PERFSTAT;
    grant select on V_$INSTANCE_CACHE_TRANSFER  to PERFSTAT;
    grant select on V_$FILE_HISTOGRAM           to PERFSTAT;
    grant select on V_$EVENT_HISTOGRAM          to PERFSTAT;
    grant select on V_$EVENT_NAME               to PERFSTAT;
    grant select on V_$SYS_TIME_MODEL           to PERFSTAT;
    grant select on V_$SESS_TIME_MODEL          to PERFSTAT;
    grant select on V_$STREAMS_CAPTURE           to PERFSTAT;
    grant select on V_$STREAMS_APPLY_COORDINATOR to PERFSTAT;
    grant select on V_$STREAMS_APPLY_READER      to PERFSTAT;
    grant select on V_$STREAMS_APPLY_SERVER      to PERFSTAT;
    grant select on V_$PROPAGATION_SENDER        to PERFSTAT;
    grant select on V_$PROPAGATION_RECEIVER      to PERFSTAT;
    grant select on V_$BUFFERED_QUEUES           to PERFSTAT;
    grant select on V_$BUFFERED_SUBSCRIBERS      to PERFSTAT;
    grant select on V_$RULE_SET                  to PERFSTAT;
    grant select on V_$OSSTAT                    to PERFSTAT;
    grant select on V_$PROCESS                   to PERFSTAT;
    grant select on V_$PROCESS_MEMORY            to PERFSTAT;
    grant select on V_$STREAMS_POOL_ADVICE       to PERFSTAT;
    grant select on V_$SGA_TARGET_ADVICE         to PERFSTAT;
    grant select on V_$SQLSTATS                  to PERFSTAT;
    grant select on V_$MUTEX_SLEEP               to PERFSTAT;
    grant select on V_$DYNAMIC_REMASTER_STATS    to PERFSTAT;
    grant select on V_$IOSTAT_FUNCTION           to PERFSTAT;
    grant select on V_$IOSTAT_FILE               to PERFSTAT;
    grant select on V_$MEMORY_TARGET_ADVICE      to PERFSTAT;
    grant select on V_$MEMORY_RESIZE_OPS         to PERFSTAT;
    grant select on V_$MEMORY_DYNAMIC_COMPONENTS to PERFSTAT;
    grant select on V_$MEMORY_CURRENT_RESIZE_OPS to PERFSTAT;
    
    
    /*  Packages  */
    grant execute on DBMS_SHARED_POOL to PERFSTAT;
    grant execute on DBMS_JOB         to PERFSTAT;
    
    "temp01.sql" 102L, 4945C                                                     102,0-1       Bot
    创建编辑权限文件脚本.
    SQL> @/home/oracle/temp01.sql
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    grant select on STATS$X_$KCBFWAIT       to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$X_$KSPPSV         to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$X_$KSPPI          to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$X_$KSXPPING       to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$V_$FILESTATXS     to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$V_$TEMPSTATXS     to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$V_$SQLXS          to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    grant select on STATS$V_$SQLSTATS_SUMMARY to PERFSTAT
                    *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    
    Grant succeeded.
    
    SQL> 
    执行权限文件脚本。

    这个导入脚本,暂时存在问题.

    userid='sys/oracle@testdb as sysdba '
    file=/home/oracle/perfstat.dmp
    full=y
    
    "impperfstat.par" 3L, 76C     
    创建编辑导入脚本impperfstat.par
    11203ora-> imp parfile=impperfstat.par 
    
    Import: Release 11.2.0.3.0 - Production on Tue Jul 30 10:49:19 2013
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    Export file created by EXPORT:V11.02.00 via direct path
    
    Warning: the objects were exported by PERFSTAT, not by you
    
    import done in AL32UTF8 character set and AL16UTF16 NCHAR character set
    . importing PERFSTAT's objects into SYS
    . . importing table        "STATS$BUFFERED_QUEUES"          0 rows imported
    . . importing table   "STATS$BUFFERED_SUBSCRIBERS"          0 rows imported
    . . importing table "STATS$BUFFER_POOL_STATISTICS"          2 rows imported
    . . importing table        "STATS$CR_BLOCK_SERVER"          0 rows imported
    . . importing table   "STATS$CURRENT_BLOCK_SERVER"          0 rows imported
    . . importing table      "STATS$DATABASE_INSTANCE"          2 rows imported
    . . importing table        "STATS$DB_CACHE_ADVICE"         40 rows imported
    . . importing table               "STATS$DLM_MISC"          0 rows imported
    . . importing table "STATS$DYNAMIC_REMASTER_STATS"          0 rows imported
    . . importing table     "STATS$ENQUEUE_STATISTICS"        161 rows imported
    . . importing table        "STATS$EVENT_HISTOGRAM"       1269 rows imported
    . . importing table             "STATS$FILESTATXS"         22 rows imported
    . . importing table         "STATS$FILE_HISTOGRAM"         86 rows imported
    . . importing table             "STATS$IDLE_EVENT"        135 rows imported
    . . importing table "STATS$INSTANCE_CACHE_TRANSFER"          0 rows imported
    . . importing table      "STATS$INSTANCE_RECOVERY"          2 rows imported
    . . importing table     "STATS$INTERCONNECT_PINGS"          0 rows imported
    . . importing table        "STATS$IOSTAT_FUNCTION"         28 rows imported
    . . importing table   "STATS$IOSTAT_FUNCTION_NAME"         14 rows imported
    . . importing table       "STATS$JAVA_POOL_ADVICE"         20 rows imported
    . . importing table                  "STATS$LATCH"       1106 rows imported
    . . importing table         "STATS$LATCH_CHILDREN"          0 rows imported
    . . importing table   "STATS$LATCH_MISSES_SUMMARY"         64 rows imported
    . . importing table           "STATS$LATCH_PARENT"          0 rows imported
    . . importing table      "STATS$LEVEL_DESCRIPTION"          5 rows imported
    . . importing table           "STATS$LIBRARYCACHE"         40 rows imported
    . . importing table   "STATS$MEMORY_DYNAMIC_COMPS"         32 rows imported
    . . importing table      "STATS$MEMORY_RESIZE_OPS"         16 rows imported
    . . importing table   "STATS$MEMORY_TARGET_ADVICE"         12 rows imported
    . . importing table            "STATS$MUTEX_SLEEP"          6 rows imported
    . . importing table                 "STATS$OSSTAT"         44 rows imported
    . . importing table             "STATS$OSSTATNAME"         22 rows imported
    . . importing table              "STATS$PARAMETER"        714 rows imported
    . . importing table                "STATS$PGASTAT"         34 rows imported
    . . importing table      "STATS$PGA_TARGET_ADVICE"         28 rows imported
    . . importing table  "STATS$PROCESS_MEMORY_ROLLUP"        116 rows imported
    . . importing table         "STATS$PROCESS_ROLLUP"         39 rows imported
    . . importing table   "STATS$PROPAGATION_RECEIVER"          0 rows imported
    . . importing table     "STATS$PROPAGATION_SENDER"          0 rows imported
    . . importing table         "STATS$RESOURCE_LIMIT"          8 rows imported
    . . importing table               "STATS$ROLLSTAT"         22 rows imported
    . . importing table       "STATS$ROWCACHE_SUMMARY"        114 rows imported
    . . importing table               "STATS$RULE_SET"          2 rows imported
    . . importing table               "STATS$SEG_STAT"         29 rows imported
    . . importing table           "STATS$SEG_STAT_OBJ"         27 rows imported
    . . importing table          "STATS$SESSION_EVENT"          0 rows imported
    . . importing table                "STATS$SESSTAT"          0 rows imported
    . . importing table        "STATS$SESS_TIME_MODEL"          0 rows imported
    . . importing table                    "STATS$SGA"          8 rows imported
    . . importing table                "STATS$SGASTAT"         55 rows imported
    . . importing table      "STATS$SGA_TARGET_ADVICE"         12 rows imported
    . . importing table     "STATS$SHARED_POOL_ADVICE"         46 rows imported
    . . importing table               "STATS$SNAPSHOT"          2 rows imported
    . . importing table                "STATS$SQLTEXT"       1589 rows imported
    . . importing table               "STATS$SQL_PLAN"       1277 rows imported
    . . importing table         "STATS$SQL_PLAN_USAGE"        111 rows imported
    . . importing table         "STATS$SQL_STATISTICS"          2 rows imported
    . . importing table            "STATS$SQL_SUMMARY"        251 rows imported
    . . importing table "STATS$SQL_WORKAREA_HISTOGRAM"         18 rows imported
    . . importing table    "STATS$STATSPACK_PARAMETER"          1 rows imported
    . . importing table      "STATS$STREAMS_APPLY_SUM"          0 rows imported
    . . importing table        "STATS$STREAMS_CAPTURE"          0 rows imported
    . . importing table    "STATS$STREAMS_POOL_ADVICE"         40 rows imported
    . . importing table                "STATS$SYSSTAT"       1276 rows imported
    . . importing table           "STATS$SYSTEM_EVENT"        156 rows imported
    . . importing table         "STATS$SYS_TIME_MODEL"         38 rows imported
    . . importing table             "STATS$TEMPSTATXS"          2 rows imported
    . . importing table                 "STATS$THREAD"          2 rows imported
    . . importing table    "STATS$TIME_MODEL_STATNAME"         19 rows imported
    . . importing table               "STATS$UNDOSTAT"         23 rows imported
    . . importing table               "STATS$WAITSTAT"         36 rows imported
    About to enable constraints...
    Import terminated successfully without warnings.
    11203ora-> 
    执行导入操作

    Purge snapshots

    • 方法一:(begin snap_id  end snap_id)
    • 方法二:(begin date & end date)
    • 方法三:(before date)
    • 方法四:(remain days)
    • 方法五:(sppurge.sql)

    如何导出perfstat schema信息?

    userid=perfstat/perfstat
    owner=perfstat
    DIRECT=y
    CONSISTENT=y
    file=/home/oracle/perfstat.dmp
    grants=y
    indexes=y
    
    ~
    ~
    "expperfstat.par" 7L, 112C                                                   7,1           All
    编辑导出脚本
    11203ora-> exp parfile=expperfstat.par 
    
    Export: Release 11.2.0.3.0 - Production on Tue Jul 30 10:02:13 2013
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    Export done in AL32UTF8 character set and AL16UTF16 NCHAR character set
    . exporting pre-schema procedural objects and actions
    . exporting foreign function library names for user PERFSTAT 
    . exporting PUBLIC type synonyms
    . exporting private type synonyms
    . exporting object type definitions for user PERFSTAT 
    About to export PERFSTAT's objects ...
    . exporting database links
    . exporting sequence numbers
    . exporting cluster definitions
    . about to export PERFSTAT's tables via Direct Path ...
    . . exporting table          STATS$BUFFERED_QUEUES          0 rows exported
    . . exporting table     STATS$BUFFERED_SUBSCRIBERS          0 rows exported
    . . exporting table   STATS$BUFFER_POOL_STATISTICS          2 rows exported
    . . exporting table          STATS$CR_BLOCK_SERVER          0 rows exported
    . . exporting table     STATS$CURRENT_BLOCK_SERVER          0 rows exported
    . . exporting table        STATS$DATABASE_INSTANCE          2 rows exported
    . . exporting table          STATS$DB_CACHE_ADVICE         40 rows exported
    . . exporting table                 STATS$DLM_MISC          0 rows exported
    . . exporting table   STATS$DYNAMIC_REMASTER_STATS          0 rows exported
    . . exporting table       STATS$ENQUEUE_STATISTICS        161 rows exported
    . . exporting table          STATS$EVENT_HISTOGRAM       1269 rows exported
    . . exporting table               STATS$FILESTATXS         22 rows exported
    . . exporting table           STATS$FILE_HISTOGRAM         86 rows exported
    . . exporting table               STATS$IDLE_EVENT        135 rows exported
    . . exporting table  STATS$INSTANCE_CACHE_TRANSFER          0 rows exported
    . . exporting table        STATS$INSTANCE_RECOVERY          2 rows exported
    . . exporting table       STATS$INTERCONNECT_PINGS          0 rows exported
    . . exporting table          STATS$IOSTAT_FUNCTION         28 rows exported
    . . exporting table     STATS$IOSTAT_FUNCTION_NAME         14 rows exported
    . . exporting table         STATS$JAVA_POOL_ADVICE         20 rows exported
    . . exporting table                    STATS$LATCH       1106 rows exported
    . . exporting table           STATS$LATCH_CHILDREN          0 rows exported
    . . exporting table     STATS$LATCH_MISSES_SUMMARY         64 rows exported
    . . exporting table             STATS$LATCH_PARENT          0 rows exported
    . . exporting table        STATS$LEVEL_DESCRIPTION          5 rows exported
    . . exporting table             STATS$LIBRARYCACHE         40 rows exported
    . . exporting table     STATS$MEMORY_DYNAMIC_COMPS         32 rows exported
    . . exporting table        STATS$MEMORY_RESIZE_OPS         16 rows exported
    . . exporting table     STATS$MEMORY_TARGET_ADVICE         12 rows exported
    . . exporting table              STATS$MUTEX_SLEEP          6 rows exported
    . . exporting table                   STATS$OSSTAT         44 rows exported
    . . exporting table               STATS$OSSTATNAME         22 rows exported
    . . exporting table                STATS$PARAMETER        714 rows exported
    . . exporting table                  STATS$PGASTAT         34 rows exported
    . . exporting table        STATS$PGA_TARGET_ADVICE         28 rows exported
    . . exporting table    STATS$PROCESS_MEMORY_ROLLUP        116 rows exported
    . . exporting table           STATS$PROCESS_ROLLUP         39 rows exported
    . . exporting table     STATS$PROPAGATION_RECEIVER          0 rows exported
    . . exporting table       STATS$PROPAGATION_SENDER          0 rows exported
    . . exporting table           STATS$RESOURCE_LIMIT          8 rows exported
    . . exporting table                 STATS$ROLLSTAT         22 rows exported
    . . exporting table         STATS$ROWCACHE_SUMMARY        114 rows exported
    . . exporting table                 STATS$RULE_SET          2 rows exported
    . . exporting table                 STATS$SEG_STAT         29 rows exported
    . . exporting table             STATS$SEG_STAT_OBJ         27 rows exported
    . . exporting table            STATS$SESSION_EVENT          0 rows exported
    . . exporting table                  STATS$SESSTAT          0 rows exported
    . . exporting table          STATS$SESS_TIME_MODEL          0 rows exported
    . . exporting table                      STATS$SGA          8 rows exported
    . . exporting table                  STATS$SGASTAT         55 rows exported
    . . exporting table        STATS$SGA_TARGET_ADVICE         12 rows exported
    . . exporting table       STATS$SHARED_POOL_ADVICE         46 rows exported
    . . exporting table                 STATS$SNAPSHOT          2 rows exported
    . . exporting table                  STATS$SQLTEXT       1589 rows exported
    . . exporting table                 STATS$SQL_PLAN       1277 rows exported
    . . exporting table           STATS$SQL_PLAN_USAGE        111 rows exported
    . . exporting table           STATS$SQL_STATISTICS          2 rows exported
    . . exporting table              STATS$SQL_SUMMARY        251 rows exported
    . . exporting table   STATS$SQL_WORKAREA_HISTOGRAM         18 rows exported
    . . exporting table      STATS$STATSPACK_PARAMETER          1 rows exported
    . . exporting table        STATS$STREAMS_APPLY_SUM          0 rows exported
    . . exporting table          STATS$STREAMS_CAPTURE          0 rows exported
    . . exporting table      STATS$STREAMS_POOL_ADVICE         40 rows exported
    . . exporting table                  STATS$SYSSTAT       1276 rows exported
    . . exporting table             STATS$SYSTEM_EVENT        156 rows exported
    . . exporting table           STATS$SYS_TIME_MODEL         38 rows exported
    . . exporting table               STATS$TEMPSTATXS          2 rows exported
    . . exporting table            STATS$TEMP_SQLSTATS
    . . exporting table                   STATS$THREAD          2 rows exported
    . . exporting table      STATS$TIME_MODEL_STATNAME         19 rows exported
    . . exporting table                 STATS$UNDOSTAT         23 rows exported
    . . exporting table                 STATS$WAITSTAT         36 rows exported
    . exporting synonyms
    . exporting views
    . exporting stored procedures
    . exporting operators
    . exporting referential integrity constraints
    . exporting triggers
    . exporting indextypes
    . exporting bitmap, functional and extensible indexes
    . exporting posttables actions
    . exporting materialized views
    . exporting snapshot logs
    . exporting job queues
    . exporting refresh groups and children
    . exporting dimensions
    . exporting post-schema procedural objects and actions
    . exporting statistics
    Export terminated successfully without warnings.
    11203ora-> 
    执行导出命令

    upgrade statspack version

    查看spdoc.txt文档. 

    随笔:

    oracle在执行查询的时候,其主要依据就是optimizer statistics 数据,所以适当的频率更新schema的optimizer statistics数据对于提高sql查询语句的性能是非常有帮助的.

  • 相关阅读:
    C#解析Json数据(利用Newtonsoft.Json库)
    巧妙解决百度地图加偏纠偏问题
    sql 日期时间函数+格式转换
    遇到sql server 遇到以零作除数错误
    js实现鼠标移到链接文字弹出一个提示层的方法
    sql语句 如何判断A表中的a列数据是否在B表中的b列中存在
    MVC使用Gantt Chart实现甘特图,管理事情进度
    jQueryGantt—集变态与惊艳于一身
    自动化测试
    小程序测试及一些限制
  • 原文地址:https://www.cnblogs.com/arcer/p/3222700.html
Copyright © 2011-2022 走看看