Your SlideShare is downloading. ×
  • Like
Sql tuning guideline
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Sql tuning guideline

  • 1,372 views
Published

 

Published in Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,372
On SlideShare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
79
Comments
0
Likes
2

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. SQL Tuning Guideline
            • Sidney · 2011 Feb 16
  • 2. Agenda
    • The Guideline to tune sql
        • Application Logic
        • Table/Column statistics
        • SQL access path
        • SQL join NL or hash Join
  • 3. Response Time
    • The core of user experience
  • 4. Why? So Slow!
        • Application Logic
        • Tune at sql level
  • 5. How to review sql
    • Verifying Optimizer Statistics
    • Reviewing the Execution Plan
    • Restructuring the SQL Statements(code change)
    • Restructuring the Indexes
  • 6. SQLT: Nice tool review top sql
    • Statistics:Tables/Indexes/Columns
    • Execution plan
      • Predication
      • Bind value
      • SQL profile
  • 7. Table/Index stats
    • Table stats
      • Last_Analyzed
      • Num_Rows
      • Sample_Size
    • Index stats
      • Last_Analyzed
      • Num_Rows
      • Sample_Size
      • DISTINCT_KEYS
      • BLEVEL
      • Clustering_Factor
  • 8. Column statistics
    • num_rows
    • num_distinct
    • density
    • num_nulls
    • num_buckets
    • histogram
    • low_value
    • high_value
  • 9. How to gather Table/Column statistics
    • Using auto method
      • exec dbms_stats.gather_table_stats('CS2_PARTY_OWNER','CS2_BKG_RQST',method_opt=>' for all columns size auto', cascade=>true);
    • For specific columns
      • exec dbms_stats.gather_table_stats('CS2_PARTY_OWNER','CS2_BKG_RQST',method_opt=>' for columns size 254 SP_COMPANY_ID', cascade=>true);
  • 10. Column Histogram
  • 11. Review execution plan
    • Driving table has the best filter
    • Join method: Nested Loop or Hash Join
    • Join order: Fewest number of rows are being returned to the next step
    • Each table is being accessed efficiently
      • index scan
      • full table scan
  • 12. Nested Loop For small number of rows(< 1000 ), with a good driving condition between the two tables
  • 13. Hash Function
  • 14. Hash Join For large data set(> 1000 ): The optimizer uses the smaller of two tables or data sources to build a hash table on the join key in memory
  • 15. Access Path
    • Full Table Scans
    • Index Scans
      • Index Unique Scans
      • Index Range Scans
      • Full Scans
      • Fast Full Index Scans
      • Index Joins
  • 16. SQL Profile
    • SQL Profiles are the new feature from 10g which is managed by Oracle Enterprise Manager as part of the Automatic SQL Tuning process. Apart from OEM, SQL Profiles can be managed through the DBMS_SQLTUNE package.
  • 17. normal usage of SQL Profile
    • Run the SQL Tuning Advisor
    • Accept the recommended SQL Profile
  • 18. advance usage: coe_xfr_sql_profile.sql
    • coe_xfr_sql_profile.sql is from SQLT tool
    • An easy way to lock the sql plan as outline
  • 19.  
  • 20. Output sql format
    • coe_xfr_sql_profile_<SID>_<PLAN_Hash_value>.SQL
    • coe_xfr_sql_profile_chpub18xajb2w_1020905707.SQL
  • 21. Q&A