oracle 11g ocp notes (25)--performance tuning

1. Memory management

1. PGA management

    PGA role:

            Temp tables, sort rows, merge bitmaps, scalars, call stacks.

           Related parameters: PGA_AGGERGATE_TARGET PAG maximum value.

                              WORKAREA_SIZE_POLICY default is AUTO

            Automatic memory management is recommended

2. SGA management:

         SHARED_POOL_SIZE

        DB_CHACHE_SIZE

        LARGE_POOL_SIZE

        STREMAS_POOL_SIZE

       JAVA_POOL_SIZE

       These are all 0 if memory management is enabled, use the SGA_TARGET LOG_BUFFER special and cannot be managed automatically.

3. Automatic memory management

       MEMORY_TARGET dynamic

      MEMORY_MAX_TARGET static.

2. Memory consultant

     v$pga_target_advice

     v$sga_target_advice

    v$memory_target_advance;

  three views. xxx_target_pactor=1 is the current value, and db_time is the database time.

     Only when statistics_level = typical or all.

 

3. SQL Tuning Consultant

      DBMS_SQLTUNE package
------------------------------------------------ ---------------------------------------

1. DBMS_SQLTUNE.CREATE_TUNING_TASK creates a task.

  1. DECLARE  
  2.   my_task_name VARCHAR2(30);  
  3.   my_sqltext   CLOB;  
  4. BEGIN  
  5.   my_sqltext   := 'select count(*) from bigtab a, smalltab b where a.object_name=b.table_name';  
  6.   my_task_name := DBMS_SQLTUNE.CREATE_TUNING_TASK(sql_text    => my_sqltext,  
  7.    user_name =>  'U1',    -- note that it is uppercase, otherwise an error will be reported and the user will be invalid  
  8.    scope       => 'COMPREHENSIVE',  
  9.    time_limit  => 60,  
  10.    task_name   => 'tuning_sql_test',  
  11.    description => 'Task to tune a query on a specified table');  
  12. END;  

In the function CREATE_TUNING_TASK , sql_text is the statement to be optimized, user_name is the user through which the statement is executed, scope is the optimization scope ( limited or comprehensive ), time_limit is the time limit of the optimization process (in seconds), task_name is the name of the optimization task, and description is the description of the optimization task .

 

2. Perform optimization tasks.

 

      sys@ORCL> exec DBMS_SQLTUNE.EXECUTE_TUNING_TASK(task_name => 'tuning_sql_test'); 

 

检查状态     SELECT task_name,status FROM USER_ADVISOR_TASKS WHERE task_name ='tuning_sql_test'; 

3. Get the result:

    SELECT DBMS_SQLTUNE.REPORT_TUNING_TASK( 'tuning_sql_test') from DUAL; 

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

 

4. SQL Access Advisor

   exec dbms_advisor.quick_tune() runs directly and quickly.

 

5. Identify and Repair Unavailable Objects

 2. Modify invalid objects and useless objects
1. Invalid objects
    Ideally, all objects are in a valid state. PL/SQL objects and views may become invalid.
    PL/SQL objects include: Procedures, functions, triggers, packages, object types
    Any data objects referenced by PL/SQL procedure objects have changed after compilation, This process is marked as INVALID.
    Oracle will always automatically recompile invalid PL/SQL objects and views, but not necessarily successfully.


    View invalid objects:
    select owner,object_name,object_type from dba_objects where status='INVALID'Attempt
    to compile invalid objects:
    alter object_type object_name compile;
    alter procedure procedure_name compile;
    alter view view_name compile;
    show errors -- view compilation errors (view not supported)
    select * from dba_dependencies; -- View object dependency table


2. Useless index
    An index consists of several index key values ​​arranged in order, where each index key value has an associated rowid, which is the rowid of the row referenced by the index key Location physical pointer.
    If the rowid of a table changes, the index is marked as useless.
    An index can become unusable for a number of reasons, the most common being that the specified table is moved using the alter table table_name move command, which changes the physical location of all rows.
    In older versions of the database, useless indexes occurred and the session returned an error message.
    In versions after 10g, if the SQL statement view uses a useless index, the statement will reuse an execution plan that does not require the index, and the execution will always succeed, but performance may be significantly reduced. Parameters can be set:
    skip_unusable_indexes -- skip useless indexes, the default value is TRUE.
    If you want to implement the function of returning error messages for useless indexes in the old version, modify the parameter to FALSE.
    alter system set skip_unusable_indexes=false;


    view useless indexes:
    select owner ,index_name from dba_indexes where status='UNUSABLE';


    rebuild index:
    alter index index_name rebuild online nologging;
    option:
    tablespace -- specify the table space, rebuild in the current table space by default.
    online -- the rebuild process will lock the specified DML command table, use the online option to avoid this situation.
    nologging -- do not generate redo for index rebuild operations, can be quickly rebuilt, but need to back up the tablespace containing the specified index immediately.
    By default, the rebuild requires a table lock and will generate redo.


    Rebuilding an index requires additional storage space, so you need to plan ahead to make sure you have available space.

 

六、database replay

 

0Overview

    Why use replay

 

  Individual operations are not captured.

1. Capture the workload.

   exec dbms_workload_capture.start_capture('play capture','DBPLY_DIR');

2. Terminate capture

exec dbms_workload_capture.finish_capture;

3. Preprocessing

 

exec dbms_workload_replay.process_capture('DBPLY_DIR');

 

 

3. Start replay

exec dbms_workload_replay.initialize_replay('play capture','DBPLY_DIR');

 

exec dbms_workload_replay.prepare_replay;
 
4. View the report
select id,capture_id,directory,start_time,end_time from dba_workload_replays;

 

        ID CAPTURE_ID DIRECTORY START_TIM END_TIME                      

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

       13 89 DBPLY_DIR 25-JUL-15 25-JUL-15                             

        12 81 DB_REPLAY 24-JUL-15 24-JUL-15                              


Set the buffer for screen output  

set long 100000

select dbms_workload_replay.report(13,'TEXT') from dual;

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325623524&siteId=291194637