Vous êtes sur la page 1sur 3

Anar Godajev http://anargodjaev.wordpress.

com/
Statspack Reports /* When installing the Statspack package, you can either change to the ORACLE_HOME/rdbms/admin directory, or fully specify the ORACLE_HOME/rdbms/admin DIRECTORY WHEN calling the installation script, SPCREATE.SQL. */ -- install statspack @?/rdbms/ADMIN/spcreate /* Enter appropriate information when prompted for the PERFSTAT user's password, default tablespace, and temporary tablespace. The SPCREATE.SQL install script runs the following scripts automatically: */ /* SPCUSR.SQL: Creates the user and grants privileges SPCTAB.SQL: Creates the tables SPCPKG.SQL: Creates the package */ -- To install without prompting SQL> CONNECT / AS SYSDBA SQL> define default_tablespace='TOOLS' SQL> define temporary_tablespace='TEMP' SQL> define perfstat_password='my_perfstat_password' SQL> @?/rdbms/ADMIN/spcreate /* -- automatic collection of statistics oracle_home/rdbms/admin/spauto.sql */ -- executing statspack SQL> CONNECT perfstat/my_perfstat_password SQL> EXECUTE statspack.snap; -- For better performance analysis, set the initialization parameter TIMED_STATISTICS to TRUE. -- Statspack will then include important timing information in the data it collects. -- create statspack report SQL> CONNECT perfstat/my_perfstat_password SQL> @?/rdbms/ADMIN/spreport -- statspack in a pl/sql block DECLARE variable snap NUMBER; BEGIN snap := statspack.snap; dbms_output.put_line(snap); END;

Anar Godajev http://anargodjaev.wordpress.com/


-- automatic statspac -- A sample script on how to do this is supplied in SPAUTO.SQL -- create statspack report without prompt SQL> SQL> SQL> SQL> SQL> CONNECT perfstat/my_perfstat_password define begin_snap=1 define end_snap=2 define report_name=batch_run @?/rdbms/ADMIN/spreport

/* When you examine the instance report, you often find high-load SQL statements that you want to examine more closely. The SQL report, SPREPSQL.SQL, displays statistics, the complete SQL text, and (if a level six snapshot has been taken), information on any SQL plan(s) associated with that statement. */ SQL> CONNECT perfstat/my_perfstat_password Connected. SQL> @?/rdbms/ADMIN/sprepsql -- truncate all statspack data SQL> CONNECT perfstat/my_perfstat_password SQL> @?/rdbms/ADMIN/sptrunc -- remove statspack SQL> CONNECT / AS SYSDBA SQL> @?/rdbms/ADMIN/spdrop /* SPDTAB.SQL - drops tables and public synonyms SPDUSR.SQL - drops the user */ -- Purge unnecessary data by using the SPPURGE.SQL script SQL> CONNECT perfstat/my_perfstat_password SQL> SET TRANSACTION USE ROLLBACK SEGMENT rbig; SQL> @?/rdbms/admin/spurge SQL> SQL> SQL> SQL> CONNECT perfstat/my_perfstat_password DEFINE losnapid=1 DEFINE hisnapid=2 @?/rdbms/admin/spurge

-- snap parameters EXECUTE STATSPACK.SNAP(i_ucomment=>'this is a temporary commment'); EXECUTE STATSPACK.MODIFY_STATSPACK_PARAMETER(i_ucomment=>'this is a commment that is saved'); EXECUTE STATSPACK.SNAP(i_snap_level=>10, i_modify_parameter=>'true'); EXECUTE STATSPACK.SNAP(i_snap_level=>6); Levels Levels Levels Levels >= >= >= >= 0 5 6 7 General Performance STATISTICS Additional Data: SQL Statements Additional Data: SQL Plans AND SQL PLAN Usage Additional data: SEGMENT LEVEL STATISTICS

Anar Godajev http://anargodjaev.wordpress.com/


Levels >= 10 Additional STATISTICS: Parent AND Child Latches

Vous aimerez peut-être aussi