INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.

Slides:



Advertisements
Similar presentations
Tuning: overview Rewrite SQL (Leccotech)Leccotech Create Index Redefine Main memory structures (SGA in Oracle) Change the Block Size Materialized Views,
Advertisements

Presented By Akin S Walter-Johnson Ms Principal PeerLabs, Inc
Office of the Accountant General (A&E) Andhra Pradesh Hyderabad
13 Copyright © 2005, Oracle. All rights reserved. Monitoring and Improving Performance.
Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
The Architecture of Oracle
1 Copyright © 2011, Oracle and/or its affiliates. All rights reserved.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Backup and Recovery Copyright System Managers LLC 2008 all rights reserved.
Acknowledgments Byron Bush, Scott S. Hilpert and Lee, JeongKyu
Oracle Architecture. Instances and Databases (1/2)
Page Footer Keed Education Oracle Database Administration Basic Copyright 2009 Keed Education BV Version Concept.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2007 all rights.
Primer on Structure& Storage Analysis Primer on Structure & Storage Analysis This presentation is supposed to give a simple and brief overview for storage.
INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Installation – Lecture 2 Copyright System Managers LLC 2007 all rights reserved.
Agenda Overview of the optimizer How SQL is executed Identifying statements that need tuning Explain Plan Modifying the plan.
1 - Oracle Server Architecture Overview
Harvard University Oracle Database Administration Session 2 System Level.
Harvard University Oracle Database Administration Session 5 Data Storage.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Oracle Database Architecture An Oracle server: –Is a database management system that provides an open, comprehensive, integrated approach to information.
INTRODUCTION TO ORACLE
Oracle Database Administration Database files Logical database structures.
9/11/2015ISYS366 - Week051 ISYS366 – Week 5-6 Database Tuning - User and Rollback Data Spaces, Recovery, Backup.
Database Systems: Design, Implementation, and Management Tenth Edition Chapter 11 Database Performance Tuning and Query Optimization.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
2 Copyright © 2006, Oracle. All rights reserved. Performance Tuning: Overview.
IT The Relational DBMS Section 06. Relational Database Theory Physical Database Design.
Chapter Oracle Server An Oracle Server consists of an Oracle database (stored data, control and log files.) The Server will support SQL to define.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
CSE 781 – DATABASE MANAGEMENT SYSTEMS Introduction To Oracle 10g Rajika Tandon.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
7202ICT Database Administration Lecture 7 Managing Database Storage Part 2 Orale Concept Manuel Chapter 3 & 4.
March 19981© Dennis Adams Associates Tuning Oracle: Key Considerations Dennis Adams 25 March 1998.
Extents, segments and blocks in detail. Database structure Database Table spaces Segment Extent Oracle block O/S block Data file logical physical.
Database Systems Slide 1 Database Systems Lecture 5 Overview of Oracle Database Architecture - Concept Manual : Chapters 1,8 Lecturer : Dr Bela Stantic.
Oracle9i Performance Tuning Chapter 2 Tuning the Buffer Cache.
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
1 Oracle Architectural Components. 1-2 Objectives Listing the structures involved in connecting a user to an Oracle server Listing the stages in processing.
Copyright  Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
Oracle Tuning Ashok Kapur Hawkeye Technology, Inc.
Copyright © Oracle Corporation, All rights reserved. 1 Oracle Architectural Components.
13 Copyright © 2006, Oracle. All rights reserved. Tuning PGA and Temporary Space.
11-1 Improve response time of interactive programs. Improve batch throughput. To ensure scalability of applications load vs. performance. Reduce system.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
1 CS 430 Database Theory Winter 2005 Lecture 16: Inside a DBMS.
Database structure and space Management. Database Structure An ORACLE database has both a physical and logical structure. By separating physical and logical.
Oracle tuning: a tutorial Saikat Chakraborty. Introduction In this session we will try to learn how to write optimized SQL statements in Oracle 8i We.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
14 Copyright © 2006, Oracle. All rights reserved. Tuning Block Space Usage.
Week 4 Lecture 2 Advanced Table Management. Learning Objectives  Create tables with large object (LOB) columns and tables that are index-organized 
D Copyright © Oracle Corporation, All rights reserved. Loading Data into a Database.
INTRODUCTION TO ORACLE DATABASE ADMINISTRATION Lynnwood Brown President System Managers LLC Introduction – Lecture 1 Copyright System Managers LLC 2003.
Chapter 5 Index and Clustering
Session 1 Module 1: Introduction to Data Integrity
10g Tuning Highlights Presenter JEREMY SCHNEIDER Senior Consultant, ITC Technology Services.
1 Chapter 9 Tuning Table Access. 2 Overview Improve performance of access to single table Explain access methods – Full Table Scan – Index – Partition-level.
Chap 5. Disk IO Distribution Chap 6. Index Architecture Written by Yong-soon Kwon Summerized By Sungchan IDS Lab
DB Tuning : Chapter 10. Optimizer Center for E-Business Technology Seoul National University Seoul, Korea 이상근 Intelligent Database Systems Lab School of.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
3 Copyright © 2004, Oracle. All rights reserved. Database Architecture Comparison.
Oracle Database Architectural Components
SQL Trace and TKPROF.
Database Tuning - User and Rollback Data Spaces, Recovery, Backup
Database Performance Tuning and Query Optimization
Chapter 15 QUERY EXECUTION.
Oracle Architectural Components
Chapter 11 Database Performance Tuning and Query Optimization
CS347 Spring 2017 – Quiz 5 Preparation - Solutions UTEID _________
Presentation transcript:

INTRODUCTION TO ORACLE Lynnwood Brown System Managers LLC Performance And Tuning – Lecture 7 Copyright System Managers LLC 2007 all rights reserved.

PERFORMANCE and TUNING It is useful to subdivide RDBMS performance analysis and tuning into two subcategories: System analysis and tuning SQL statement tuning System analysis and tuning can be divided into three subcategories: Memory CPU IO

SYSTEM PERFORMANCE ANALYSIS On Windows machines use Task Manager to investigate CPU and memory usage: Memory usage should be less then 90%. CPU usage should be less then 90%.

SYSTEM PERFORMANCE ANALYSIS On UNIX machines use the OS utilities such as TOP or SAR to get CPU utilization statistics: oracle% sar -u 09:30:53 %usr %sys %wio %idle 09:30: CPU statistics - %SYS greater then 20% is bad Disk IO statistics - %WIO greater then 15% is bad Copyright System Managers LLC 2007 all rights reserved.

SYSTEM PERFORMANCE ANALYSIS Useful UNIX Commands: swap - Will provide us with the usage of swap space including the RAM. sar - Will provide CPU usage and system idle time information. top - Will provide information about top CPU consuming processes vmstat - Will provide information about process paging and swapping Copyright System Managers LLC 2007 all rights reserved.

SYSTEM PERFORMANCE ANALYSIS File placement rules Make sure that log files and archived log files are NOT on the same disk as data files. Place UNDO and System Tablespace data files on the same disks, Index and Data files on their own disk, and TEMP (sorting) data files on its own disk. Consider using RAID level 5 disk striping to stripe your data files across multiple disks Copyright System Managers LLC 2007 all rights reserved.

SYSTEM PERFORMANCE ANALYSIS Memory management tuning – How well is Oracle managing the memory that is allocated to it. The DBA should compute the following memory management statistics: Database buffer cache hit ratio greater then 95% Redo log buffer waits equal to 0 Data dictionary cache less then 10% Library cache between 1% and 3% Sort area ratio – Sorts performed in memory versus. sorts performed on the disk should be around 10%

SYSTEM PERFORMANCE ANALYSIS Dynamic Performance Views The Oracle RDBMS places system performance information in its dynamic performance views: Database buffer cache hit ratio – V$SYSSTAT Redo log buffer waits – V$SYSSTAT Data dictionary cache – V$ROWCACHE Library cache – V$LIBRARYCACHE Sort area ratio – V$SYSSTAT Copyright System Managers LLC 2007 all rights reserved.

SYSTEM PERFORMANCE ANALYSIS Oracle database tuning parameters are located in the init.ora file. These parameters control the size of the Oracle SGA. The parameters include: DB_BLOCK_BUFFERS - Database buffer cache SHARED_POOL_SIZE – The library cache plus the data dictionary cache are called the shared pool LOG_BUFFERS - Redo log buffer SORT_AREA_SIZE – Sort buffer

System Performance:Table Fragmentation Fragmentation occurs: Over time as rows get deleted, updated or inserted. A segment is fragmented when some free space exists in the blocks but not sufficient space in any of them for Oracle to be able to insert a new one. When a row that originally fitted into one data block is updated so that the overall row length increases, and the block's free space is already completely filled, Oracle migrates the data for the row to a new data block: but Oracle must scan more than one data block to retrieve the information for that row.

System Performance:Table Fragmentation SQL> analyze table scott, BIG1 compute statistics; SQL> select table_name,round((blocks*8),2)||'kb' "size"2 from user_tables3 where table_name = 'BIG1'; TABLE_NAME size BIG kb SQL> select table_name,round((num_rows*avg_row_len/1024),2 )||'kb' "size"2 from user_tables3 where table_name = 'BIG1'; TABLE_NAME size BIG kb Wasted space in table = = Kb

System Performance:Table Fragmentation SQL> alter table BIG1 move; SQL> analyze table scott, BIG1 compute statistics; SQL> select table_name,round((blocks*8),2)||'kb' "size"2 from user_tables3 where table_name = 'BIG1'; TABLE_NAME size BIG kb SQL> select table_name,round((num_rows*avg_row_len/1024),2 )||'kb' "size"2 from user_tables3 where table_name = 'BIG1'; TABLE_NAME size BIG kb Wasted space in table = = 7497Kb

System Performance:Table Fragmentation By following a simple set of rules, fragmentation at the extent level can be eliminated: Rule1: All the segments in a tablespace should have exactly the same extent size. This ensures that any free extent in a tablespace can always be used for any segment in the tablespace. Rule2: All segments should inherit the storage values from the storage clause of the tablespace. Rule3: Very large segments (bigger that 4G) should be should be placed their own tablespaces that do not contain any other data.

System Performance:Table Fragmentation It is worthwhile to rebuild a table if the tables HWM does not change after data has been deleted from the table : SQL > select (blocks - empty_blocks -1) “HWM” from dba_tables; The data dictionary view DBA_TABLES provides fragmentation statistics after “ANALYZE” or “DBMS_STATS” has been run. Fragmentation Columns in DBA_TABLES: CHAIN_CNT is increasing due to migrated rows AVG_SPACE is increasing because of deletes

SQL STATEMENT TUNING Table Access Full Table Scan - In a FTS operation, the entire table is read up to the high water mark (HWM). –The HWM marks the last block in the table that has ever had data written to it. Index lookup - Data is accessed by looking up key values in an index and returning rowids. –A rowid uniquely identifies an individual row.

SQL STATEMENT TUNING Query processing can be divided into 7 phases: Syntactic - checks the syntax of the query Semantic - checks that all objects exist and are accessible View Merging - rewrites query as join on base tables Statement Transformation - rewrites query transforming complex constructs into simpler ones Copyright System Managers LLC 2007 all rights reserved.

SQL STATEMENT TUNING Optimization - Determines the optimal access path for the query to take (init.ora parameter: OPTIMIZER_GOAL=RULE/CHOOSE). –Rule Based Optimizer (RBO) - Uses a set of heuristics to determine the objects access path –. Cost Based Optimizer (CBO) - Uses table statistics to analyze the relative costs of accessing objects. Query/Explain Evaluation Plan Generation Query/Explain Evaluation Plan Execution

SQL STATEMENT TUNING An explain plan is a representation of the access path that is taken when a query is executed Example FTS explain/query plan for: SQL> select * from dual; Query Plan SELECT STATEMENT [CHOOSE] Cost= TABLE ACCESS FULL DUAL Copyright System Managers LLC 2007 all rights reserved.

SQL STATEMENT TUNING Example of an index lookup explain plan for: SQL > select empno,ename from emp where empno=10; Query Plan SELECT STATEMENT [CHOOSE] Cost=TABLE ACCESS BY ROWID EMP [ANALYZED] INDEX UNIQUE SCAN EMP_I1 Copyright System Managers LLC 2007 all rights reserved.

SQL STATEMENT TUNING Is a view being accessed? Get the view text from DBA_VIEWS and tune the SQL that the view is based on. SQL > select text from dba_views where view_name = ‘MY_VIEW’; Copyright System Managers LLC 2007 all rights reserved.

SQL STATEMENT TUNING Indexes are optional database structures associated with tables and are created to speed access to data within a table. B-TREE most common index type used in OLTP applications Bit Mapped - Specifically designed to improve performance of queries in data warehouse (OLAP) applications Creating a B-Tree index: Create index I_my_index on table_name(column_name);

SQL STATEMENT TUNING Index Rules Index columns that are used in WHERE clauses Do not index small tables Index columns that are used in “JOIN” clauses Only index columns with good selectivity. The query should return no more then 25 – 30 % of the data in the table Columns that are frequently modified should not be indexed Columns that only appear in WHERE clauses with functions or operators should not be indexed.

SQL STATEMENT TUNING SQL statement tuning can be accomplished using the SQL*PLUS feature AUTOTRACE. This will display a short version of the EXPLAIN plan on the screen after the SQL statement is executed. To turn on AUTOTRACE SQL> set autotrace traceonly explain Copyright System Managers LLC 2007 all rights reserved.

SQL STATEMENT TUNING A file containing the SQL trace information can be created by altering the end user SQL*PLUS session. The trace information will be written into the trace file (.trc file extension) directory. This directory is pointed to by the init.ora parameter USER_DUMP_DEST. SQL > ALTER SESSION SET SQL_TRACE = TRUE; TKPROF is an Oracle supplied OS level utility that is used to format the SQL trace file. C:> TKPROF.trc sql_results.sav SORT=(EXECPU,FCHCPU) EXPLAIN= user_ID/passwd