dba best practices ow08 129450

Upload: austinfru

Post on 07-Aug-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/21/2019 DBA Best Practices Ow08 129450

    1/50

    DBA Best Practices:A Primer on Managing Oracle Databases

    Leng Leng TanVice President, Systems and Applications Management

  • 8/21/2019 DBA Best Practices Ow08 129450

    2/50

    The following is intended to outline our generalproduct direction. It is intended for informationpurposes only, and may not be incorporated into anycontract. It is not a commitment to deliver anymaterial, code, or functionality, and should not be

    relied upon in making purchasing decisions.The development, release, and timing of anyfeatures or functionality described for Oraclesproducts remains at the sole discretion of Oracle.

  • 8/21/2019 DBA Best Practices Ow08 129450

    3/50

    Top 3 DBA Activities

    1. Performance Diagnosis

    2. SQL Optimization

    3. Space Management

    Source: IOUG DBA Survey

  • 8/21/2019 DBA Best Practices Ow08 129450

    4/50

    Top 3 DBA Activities

    1. Performance Diagnosis

    2. SQL Optimization

    3. Space Management

    Source: IOUG DBA Survey

    Top10BestPra

    ctices

    for

  • 8/21/2019 DBA Best Practices Ow08 129450

    5/50

    Performance Diagnostics

    Performance Diagnostics

    SQL Optimization

    Space Management

    Q & A

  • 8/21/2019 DBA Best Practices Ow08 129450

    6/50

    Performance Diagnostics Topics

    Key Concepts

    Automatic System Diagnostics Manual System Diagnostics

    Advanced Topics

    Targeted analysis

    Comparative analysis

  • 8/21/2019 DBA Best Practices Ow08 129450

    7/50

    Key Concepts

    DB Time

    Total time in database calls by foreground sessions

    Includes CPU time, IO time and non-idle wait time

    DB Time response time

    Total DB time = sum of DB time for all active sessions

    Goal: To Reduce Total DB time

    Active Session

    Session currently spending time in a database call, i.e., accruing DBtime

    Average Active Sessions

    Average Active Sessions is a new metric for measuring DB load

    = Wall-Clock (Elapsed) Time

    DB Time

  • 8/21/2019 DBA Best Practices Ow08 129450

    8/50

    Automatic System Diagnostics using ADDM

    Use ADDM (AutomaticDatabase Diagnostic Monitor)

    for database-wideperformance diagnostic

    Self-diagnostic engine in thedatabase

    Helps resolve current and pastproblems

    In 11g, a RAC specialist as well!

    Provides impact and benefit

    analysis, non problem areas Runs proactively out of the box,

    reactively when requiredSQLAdvisor

    High-loadSQL

    IO / CPUissues

    RAC issues

    Automatic Diagnostic Engine

    Snapshots in

    Automatic Workload

    Repository

    Self-Diagnostic Engine inside DB

    SystemResource

    Advice

    Network +DB config

    Advice

    #10B

    P

  • 8/21/2019 DBA Best Practices Ow08 129450

    9/50

  • 8/21/2019 DBA Best Practices Ow08 129450

    10/50

    Manual Performance Diagnostics

    EM Performance Page facilitates manual performanceanalysis

    Method (Advanced):

    Observe Average Active Sessions graph Click on the Big Stuff

    Answers the who and what of the problem

    Who is slowing down the system?

    What is that person/process doing? Click!

  • 8/21/2019 DBA Best Practices Ow08 129450

    11/50

  • 8/21/2019 DBA Best Practices Ow08 129450

    12/50

  • 8/21/2019 DBA Best Practices Ow08 129450

    13/50

    Targeted Performance Analysis

    Use ASH (Active Session History) for targeted performanceanalysis into different dimensions:

    1st dimension by a Time, then by

    SQL ID

    Session ID Wait Class

    Service, Module, Action, Client ID

    Performance

    Time*

    Range

    #9BP

  • 8/21/2019 DBA Best Practices Ow08 129450

    14/50

    ASH Report: Over 5 mins by a SQL

    Main Sections

  • 8/21/2019 DBA Best Practices Ow08 129450

    15/50

    ASH Report:

    Top Events for that SQL

  • 8/21/2019 DBA Best Practices Ow08 129450

    16/50

    ASH Report:

    Activity for that SQL over the same 5 mins

  • 8/21/2019 DBA Best Practices Ow08 129450

    17/50

    Comparative Performance Analysis

    Use Automatic WorkloadRepository (AWR) Baselinefor comparativeperformance analysis to

    Guide set alert thresholds

    Monitor performance

    Compare advisor reports

    Enables performance

    comparison of two periods Makes analysis of workload

    variations and performancediagnosis easier

    Automatic creation and

    management of referenceAWR baselines

    Out-of-box Moving WindowAWR Baseline in 11g

    time

    Performance

    Baseline

    Actual

    #8BP

  • 8/21/2019 DBA Best Practices Ow08 129450

    18/50

    AWR Compare Period Report

  • 8/21/2019 DBA Best Practices Ow08 129450

    19/50

    AWR Compare Period Report:Configuration

  • 8/21/2019 DBA Best Practices Ow08 129450

    20/50

    AWR Compare Period Report:

    Load Profile

  • 8/21/2019 DBA Best Practices Ow08 129450

    21/50

    AWR Compare Period Report:Top SQL by Elapsed Time

  • 8/21/2019 DBA Best Practices Ow08 129450

    22/50

    SQL Optimization

    Performance Diagnostics

    SQL Optimization

    Space Management

    Q & A

  • 8/21/2019 DBA Best Practices Ow08 129450

    23/50

    SQL Optimization Topics

    Manual SQL Tuning

    Automatic SQL Tuning Optimizer Statistics Management

  • 8/21/2019 DBA Best Practices Ow08 129450

    24/50

    Shows whats happening inside SQLexecution

    Automatically monitors long runningSQL

    Enabled out-of-the-box with noperformance impact

    Monitors each SQL execution

    Exposes monitoring statistics Global execution level

    Plan operation level

    Parallel Execution level

    Use Real-time SQL Monitoring

    to Understand SQL Execution#7

    BP

  • 8/21/2019 DBA Best Practices Ow08 129450

    25/50

    Real-time SQL Monitoring

    Demo

  • 8/21/2019 DBA Best Practices Ow08 129450

    26/50

    SQL Monitoring Use Case: Big Plans

  • 8/21/2019 DBA Best Practices Ow08 129450

    27/50

    SQL Monitoring Use Case: Big Plans

  • 8/21/2019 DBA Best Practices Ow08 129450

    28/50

    SQL Monitoring Use Case: Big Plans

  • 8/21/2019 DBA Best Practices Ow08 129450

    29/50

    SQL Monitoring Use Case: Big Plans

  • 8/21/2019 DBA Best Practices Ow08 129450

    30/50

    Statistics Analysis

    Use SQL Tuning Advisor to Tune SQL

    Access Structure

    Analysis (SingleSQL)

    SQL DesignAnalysis

    Plan Tuning (SQLProfiling)

    Comprehensive Analysis

    Gather Missing orStale Statistics

    Create a SQLProfile

    Add Missing

    Indexes (B* Tree)

    Modify SQLConstructs

    RecommendationSQL TuningAdvisor

    SQL

    #6BP

  • 8/21/2019 DBA Best Practices Ow08 129450

    31/50

    Live vs. Remote Tuning

    Resource Consumption Limited mode: Resource consumption minimal

    Stats, index and SQL restructure analysis is cheap

    Average is less than 1 second per SQL statement Comprehensive mode: Resource consumption may be significant

    SQL Profiling can potentially consume non-trivial resources

    Roughly comparable to amount of resources/time consumed when executingSQL statement(s)

    Live tuning Run SQL Tuning Advisor in Limited mode only if system does not have spare

    resources otherwise run in Comprehensive mode (recommended)

    Remote tuning Tuning remotely if

    Cumulative resources/time consumed by all SQL statements significant

    System cannot spare resources

    Use SQL Profile and SQL Tuning Set export/import capabilities

  • 8/21/2019 DBA Best Practices Ow08 129450

    32/50

    More Best Practices when using

    SQL Tuning Advisor Use Automatic SQL Capture feature of SQL Tuning Set (STS) to

    capture SQL Workload

    Always validate SQL Profiles before enabling them

    For remote tuning, ensure test system is similar to productionsystem

    Schema

    Data distribution

    Volume

    If test system smaller than production, set optimizer statsmanually

    DBMS_SQLTUNE.ACCEPT_SQL_PROFILE (task_name => , category => MY_CATEGORY);

    ALTER SESSION SET SQLTUNE_CATEGORY=MY_CATEGORY ;

  • 8/21/2019 DBA Best Practices Ow08 129450

    33/50

    Automatic SQL Tuning

    Automatically captures high-load SQL

    Automatically tunes SQLwithout changing applicationby creating SQL Profiles

    Automatically validates SQL

    Profiles by test executing them Automatically implements

    (optional) greatly improvedSQL plans

    Automatically reports analysis Automatically runs during

    maintenance window

    PackagedApps

    CustomApps

    SQL Tuning Advisor

    Auto CaptureHigh-Load SQL

    SQLProfiles

    Nightly

    Well-tuned SQL

    Automatic

    implementManuallyimplement

    SQLAnalysis

    Report

  • 8/21/2019 DBA Best Practices Ow08 129450

    34/50

    Optimizer Statistics Management

    Use Automatic statistics collection tomanage Optimizer Statistics

    Out-of-the box, runs in maintenance window

    configuration can be changed

    Restartable Gathers statistics on user and dictionary

    objects

    Parameters chosen automatically based on

    DML monitoring

    Column usage monitoring

    Iterative sampling

    Uses new collection algorithm with accuracyof compute and speed faster than samplingof 1%

    Incrementally maintains statistics forpartitioned tables very efficient

    #5BP

  • 8/21/2019 DBA Best Practices Ow08 129450

    35/50

    More Best Practices on Statistics

    Collection Gather statistics for all objects (dictionary and user objects)

    Volatile objects Gathers statistics when object at max size and then lock table

    Delete all statistics and lock table dynamic sampling will be used Restoring old optimizer statistics

    Used when new stats result in poor execution plan selection

    Scope: Table, schema and database

    History maintained for 30 days API: DBMS_STATS.RESTORE_TABLE_STATS

    Don't use the ANALYZE command Officially obsolete for optimizer statistics

    Cannot gather GLOBAL statistics for partitioned objects

    Cannot gather statistics for external tables, fixed tables, etc.

    Invalidates/recompiles all dependent cursors at once

    DBMS_STATS marks cursors as unusable and recompiles gradually

  • 8/21/2019 DBA Best Practices Ow08 129450

    36/50

    Optimizer Statistics Validation

    Use SQL Performance Analyzer(SPA) to validate statisticsrefresh1. Capture SQL workload in STS using

    automatic cursor cache capturecapability

    2. Execute SPA pre-change trial

    3. Refresh statistics using PENDINGoption

    4. Execute SPA post-change trial5. Run SPA report comparing SQL

    execution statistics

    Before PUBLISHing stats Remediate individual SQL for plan

    few regressions Revert to old statistics if too many

    regressions observed

    Analysis Report

    Compare SQLPerformance

    Post-changeexecutionsstats

    Pre-changeexecutionsstats

    SQLWorkload

    SQL Performance Analyzer(SPA)

    #4BP

    Real Application Testing applicable for Pre 11g

  • 8/21/2019 DBA Best Practices Ow08 129450

    37/50

    Real Application Testing applicable for Pre-11gDatabase Releases

    SQL Performance Analyzer (SPA)

    Capture on 9i, 10.1, 10.2 database releases

    Test changes in 10.2 & above Database Replay

    Capture on 9i, 10.2 database releases

    Test changes in 11.1 & above

    Test Changes InCapture FromFeature

    11g10g R2

    11g9i R2Database Replay

    10g R2 or 11g10g R2

    10g R2 or 11g10g R1

    10g R2 or 11g9i R2SQL Performance Analyzer

    Performance Diagnostics

  • 8/21/2019 DBA Best Practices Ow08 129450

    38/50

    Space Management

    g

    SQL Optimization

    Space Management

    Q & A

  • 8/21/2019 DBA Best Practices Ow08 129450

    39/50

    Space Management Topics

    Permanent Tablespace Management

    Extent management

    Segment space management

    Temporary Tablespace Management

    RAC

    Goals Optimize space usage by eliminating/ minimizing

    fragmentation Optimize data access and transaction performance

  • 8/21/2019 DBA Best Practices Ow08 129450

    40/50

    Space managed locally by bitmapsin data file headers

    Eliminates external fragmentation Efficient space utilization

    Performance

    Serialization of space managementat file level

    Space management faster by 100-200%

    Two extent management types Auto-allocate (recommended):Extent size determined by database

    Uniform: All extents of same size

    Permanent Tablespace Management

    Use Automatic Segment SpaceManagement for Segment Mgmt

    Segment free space managed usingbitmaps

    Easier management: PCTUSED,FREELISTS, FREELIST GROUPSdont have to be tuned or set

    Superior performance

    Automatically manages contention onmeta-data blocks

    Inter-instance data block contentionreduced by dynamic instance affinity

    Minimizes internal fragmentation

    Use Locally ManagedTablespace for Extent Mgmt

    #3BP

    Automatic Segment Space Mgmt (ASSM)

  • 8/21/2019 DBA Best Practices Ow08 129450

    41/50

    Automatic Segment Space Mgmt (ASSM)vs. Manual Segment Space Mgmt (MSSM)

    0

    1

    2

    3

    4

    1 2 4 8 16 32

    ASSM

    MSSM

    Respons

    eTime

    Insert Workload

    0

    2

    4

    6

    8

    1 2 4 8

    ASSM

    MSSM

    Concurrent Users

    ResponseTime

    Mixed DML Workload

    Concurrent Users

    Internal Fragmentation

  • 8/21/2019 DBA Best Practices Ow08 129450

    42/50

    Fragmentation of space within a segment Space under-utilization below HWM

    Although minimized, can still occur in ASSM tablespace

    Performance Impact: slows certain access paths, e.g., full table scan Online Segment Shrink remedies internal fragmentation

    ROW MOVEMENT must be ENABLED for heap organized segments

    Segment must be in ASSM, locally managed tablespace

    Automatic Segment Advisor evaluates segments for fragmentation and makesappropriate recommendations

    Internal Fragmentation

    YYNParallel

    YNYSegment Level Reorg

    NNYDependecy

    Maintenance

    NNYIncremental

    NNYIn-place

    NYYOnline

    Alter MOVEOnline RedefShrinkSpace Operations

    Note: For tables with large number of indexes, reorg is faster

    T T bl M t

  • 8/21/2019 DBA Best Practices Ow08 129450

    43/50

    Temporary Tablespace Management

    Temporary Data Data generated by operations like bitmap merges, hash join,

    bitmap index creation, sort

    Persists only for duration of a transaction or session Media and instance recovery is not required

    High concurrency of space management operations is verycritical

    Use Temporary Tablespace for temporary data ALTER DATABASE DEFAULT TEMPORARY TABLESPACE

    tablespace_name; Use Locally Managed Temporary Tablespace

    Allows high concurrency space management

    In steady state all space metadata cached in SGA

    Operations serialized by SGA latch instead of db wide ST enqueue Can be shrunk using SHRINK SPACE and/or SHRINK TEMPFILE

    commands

    #2BP

    M B t P ti T

  • 8/21/2019 DBA Best Practices Ow08 129450

    44/50

    Guidelines for choosing extent size 5M-10M:

    For DSS, OLAP applications involving huge sorts, hash joins

    Large temporary lobs are predominant 64K or multiple:

    Global temporary tables are predominant and amount of data loaded is small Application is predominantly OLTP

    V$TEMPSEG_USAGE can be used to monitor space usage andworkload distribution

    SESSION_NUM USERNAME SEGTYPE BLOCKS TABLESPACE

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

    101 SCOTT SORT 128 TEMP102 SCOTT LOB_DATA 128 TEMP

    103 SYS HASH 256 TEMP

    More Best Practices on Temporary

    Tablespace Management

    B t P ti f T T bl

  • 8/21/2019 DBA Best Practices Ow08 129450

    45/50

    Best Practices for Temporary Tablespace

    Management in RAC

    Use a single Temporary Tablespace for entire RACdatabase

    No special configuration is needed

    Each instance dynamically caches extents it hasaffinity to in its SGA

    Sharing of space between instances happenstransparently and dynamically

    Add space when number of waits on SS enqueueincreases

    Use Enterprise Manager to Manage

  • 8/21/2019 DBA Best Practices Ow08 129450

    46/50

    Use Enterprise Manager to Manage

    Database Grid Control or Database Control (out-of-the-box)

    #1BP

    Top 3 DBA Activities

    tices

  • 8/21/2019 DBA Best Practices Ow08 129450

    47/50

    p

    #10 Use ADDM for database-wide performance diagnostic#9 Use ASH for targeted performance analysis

    #8 Use AWR Baseline for comparative performance analysis

    #7 Use Real-time SQL Monitoring to understand SQL execution

    #6 Use SQL Tuning Advisor to tune SQL

    #5 Use Automatic statistics collection to manage optimizer statistics

    #4 Use SQL Performance Analyzer (SPA) to validate statistics refresh

    #3 Use Locally Managed TS with Auto-Allocate & Automatic SegmentSpace Management for Permanent Tablespace

    #2 Use Locally Managed Temporary Tablespace

    #1 Use Enterprise Manager to manage database

    Top10BestPrac

    tices

    for

    Recommended Campground Demos

  • 8/21/2019 DBA Best Practices Ow08 129450

    48/50

    Recommended Campground Demos

    Moscone West

    Exhibit Hall

    Change Management & Data Masking for DBAs

    Moscone West

    Exhibit Hall

    Complete Data Center Management

    Moscone West

    Exhibit Hall

    Application Quality Management

    Moscone West

    Exhibit Hall

    Self-Managing Database: Automatic Application & SQLTuning

    Moscone West

    Exhibit Hall

    Self-Managing Database: Automatic Fault Diagnostics

    Moscone West

    Exhibit Hall

    Self-Managing Database: Automatic Performance Diagnostics

    Moscone WestExhibit Hall

    Oracle Real Application Testing: Database Replay andSQL Performance Analyzer

    LocationDemo

    Recommended Sessions

  • 8/21/2019 DBA Best Practices Ow08 129450

    49/50

    Mos South: 10311:30Wed, 9/24Oracle Recovery Manager (RMAN) Best Practices

    Mos South: 3031:30Thursday, 9/25Proactive Performance Monitoring with Baselines andAdaptive Thresholds

    LocationTimeDateSession Title

    Mos South: 3022:30Monday, 9/22Performance Fundamentals for Oracle DB 10g and 11g

    Mos West : 200311:30Tuesday, 9/23Advanced Performance Diagnostics: What the GUIDoesn't Tell You

    Mos West: 20034:00Monday, 9/22Oracle Enterprise Manager: Oracle's Management

    Solution for Your Enterprise

    Mos South: 3039:00Wed, 9/24Storage Monitoring Made Easy: Diagnosing I/OPerformance Problems

    Mos South: 3035:00Tuesday, 9/23Successful Upgrade Secrets: PreventingPerformance Problems with Database Replay

    Mos South: 3031:00Tuesday, 9/23Demystifying SQL Tuning: Tips and Techniques for SQLExperts

    Mos West: 20011:00Wed, 9/24SQL Tuning Roundtable with the Experts

    Recommended Sessions

  • 8/21/2019 DBA Best Practices Ow08 129450

    50/50