Oracle 10g Database Administrator: Implementation and Administration

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

Overview of performance tuning strategies Oracle Performance Tuning Allan Young June 2008.
© IBM Corporation Informix Chat with the Labs John F. Miller III Unlocking the Mysteries Behind Update Statistics STSM.
Manipulating Data Schedule: Timing Topic 60 minutes Lecture
Module 17 Tracing Access to SQL Server 2008 R2. Module Overview Capturing Activity using SQL Server Profiler Improving Performance with the Database Engine.
Transaction Processing. Objectives After completing this lesson, you should be able to do the following: –Define transactions effectively for an application.
9-1 Copyright  Oracle Corporation, All rights reserved. Data Manipulation Language A DML statement is executed when you: – Add new rows to a table.
12 Copyright © 2005, Oracle. All rights reserved. Proactive Maintenance.
Business Intelligence Michael Gross Tina Larsell Chad Anderson.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 11: Monitoring Server Performance.
Chapter 14 Chapter 14: Server Monitoring and Optimization.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 11 Database Performance Tuning and Query Optimization.
9 Copyright © 2009, Oracle. All rights reserved. Managing Data Concurrency.
Oracle 10g Database Administrator: Implementation and Administration Chapter 14 Proactive Maintenance.
Database Administration Part 1 Chapter Six CSCI260 Database Applications.
Chapter 5 Data Manipulation and Transaction Control Oracle 10g: SQL
Chapter 9 Overview  Reasons to monitor SQL Server  Performance Monitoring and Tuning  Tools for Monitoring SQL Server  Common Monitoring and Tuning.
Module 8: Monitoring SQL Server for Performance. Overview Why to Monitor SQL Server Performance Monitoring and Tuning Tools for Monitoring SQL Server.
Module 5: Data Access. Overview Introduce database components involved in data access Introduce concepts of Transact -SQL and Procedural SQL as tools.
Virtual Memory Tuning   You can improve a server’s performance by optimizing the way the paging file is used   You may want to size the paging file.
Module 8: Server Management. Overview Server-level and instance-level resources such as memory and processes Database-level resources such as logical.
Course Topics Administering SQL Server 2012 Jump Start 01 | Install and Configure SQL Server04 | Manage Data 02 | Maintain Instances and Databases05 |
Introduction and simple using of Oracle Logistics Information System Yaxian Yao
12 Copyright © 2007, Oracle. All rights reserved. Database Maintenance.
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.
Oracle9i Database Administrator: Implementation and Administration 1 Chapter 9 Index Management.
1Introduction Objectives 1-2 Course Objectives 1-3 Oracle Products 1-4 Relational Database Systems 1-5 How the Data Is Organized 1-6 Integrity Constraints.
Oracle Database Administration Lecture 6 Indexes, Optimizer, Hints.
By Lecturer / Aisha Dawood 1.  You can control the number of dispatcher processes in the instance. Unlike the number of shared servers, the number of.
Physical Database Design & Performance. Optimizing for Query Performance For DBs with high retrieval traffic as compared to maintenance traffic, optimizing.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
Materialized Views Acknowledgement to Author: Willie Albino.
The Self-Managing Database: Guided Application and SQL Tuning Mohamed Ziauddin Consulting Member of Technical Staff Oracle Corporation Session id:
1 Chapter 7 Optimizing the Optimizer. 2 The Oracle Optimizer is… About query optimization Is a sophisticated set of algorithms Choosing the fastest approach.
Administration and Monitoring the Database Oracle 10g.
Oracle Locking Michael Messina Principal Database Analyst Indiana University.
Oracle Tuning Considerations. Agenda Why Tune ? Why Tune ? Ways to Improve Performance Ways to Improve Performance Hardware Hardware Software Software.
Triggers A Quick Reference and Summary BIT 275. Triggers SQL code permits you to access only one table for an INSERT, UPDATE, or DELETE statement. The.
By Lecturer / Aisha Dawood 1.  Dedicated and Shared Server Processes  Configuring Oracle Database for Shared Server  Oracle Database Background Processes.
9 Copyright © 2007, Oracle. All rights reserved. Managing Data and Concurrency.
Oracle9i Performance Tuning Chapter 12 Tuning Tools.
Database Design and Management CPTG /23/2015Chapter 12 of 38 Functions of a Database Store data Store data School: student records, class schedules,
Objectives After completing this lesson, you should be able to do the following: Describe each data manipulation language (DML) statement Insert rows.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
By Shanna Epstein IS 257 September 16, Cnet.com Provides information, tools, and advice to help customers decide what to buy and how to get the.
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.
8 Copyright © 2005, Oracle. All rights reserved. Managing Data.
Transactions and Locks A Quick Reference and Summary BIT 275.
7 Copyright © 2005, Oracle. All rights reserved. Managing Undo Data.
Enterprise Database Administration & Deployment SIG ▪ 313M ▪ Sept 29, 2005 ▪ 10:15 AM SQL Server 2005 Performance Diagnosis and Tuning using SQL Tools.
Oracle 10g Database Administrator: Implementation and Administration Chapter 5 Basic Storage Concepts and Settings.
SQL/Lesson 7/Slide 1 of 32 Implementing Indexes Objectives In this lesson, you will learn to: * Create a clustered index * Create a nonclustered index.
Physical Database Design Purpose- translate the logical description of data into the technical specifications for storing and retrieving data Goal - create.
1 Copyright © 2005, Oracle. All rights reserved. Following a Tuning Methodology.
Module 11: Managing Transactions and Locks
Oracle 10g Database Administrator: Implementation and Administration Chapter 10 Basic Data Management.
Oracle9i Developer: PL/SQL Programming Chapter 11 Performance Tuning.
8 Copyright © 2005, Oracle. All rights reserved. Gathering Statistics.
Database Systems, 8 th Edition SQL Performance Tuning Evaluated from client perspective –Most current relational DBMSs perform automatic query optimization.
Copyright Sammamish Software Services All rights reserved. 1 Prog 140  SQL Server Performance Monitoring and Tuning.
Does the Optimistic Concurrency resolve your blocking problems Margarita Naumova, SQL Master Academy.
Oracle 11g: SQL Chapter 5 Data Manipulation and Transaction Control.
Tuning Oracle SQL The Basics of Efficient SQL Common Sense Indexing
SQL Server Monitoring Overview
Oracle 10g Database Administrator: Implementation and Administration
Database Performance Tuning and Query Optimization
Chapter 11 Database Performance Tuning and Query Optimization
Presentation transcript:

Oracle 10g Database Administrator: Implementation and Administration Chapter 13 Performance Monitoring

Objectives Discover performance and performance monitoring Learn about different tools used for performance monitoring Learn about gathering statistics Discover invalidated database objects Oracle 10g Database Administrator: Implementation and Administration

Objectives (continued) Find out about performance metrics Examine and change performance metrics React to performance issues Learn about locks Oracle 10g Database Administrator: Implementation and Administration

Introduction to Performance Monitoring Performance: measure of how fast the database reacts to access data in the database Measure of how quickly DB reacts to request/activity Performance monitoring: action of monitoring database speed Most easily performed with custom software tools There are numerous tools available with Oracle Database software, at no extra cost These tools, along with more complex methods using command-line interfaces, allow access to underlying metadata and statistics within an Oracle database Oracle 10g Database Administrator: Implementation and Administration

Different Tools for Performance Monitoring Tools that can be used for performance monitoring EXPLAIN PLAIN Autotrace in SQL*Plus SQL Trace and TKPROF End-to-End tracing with TRCSESS STATSPACK V$ Views The Wait Event Interface Drill-Down in the Wait Event Interface Oracle 10g Database Administrator: Implementation and Administration

Different Tools for Performance Monitoring (continued) Tools that can be used for performance monitoring Drill-Down in the Wait Event Interface TopNNNN Third-Party tools: Spotlight Operating system tools Windows Performance Monitor Unix utilities: sar, vmstat, mpstat, and iostat Oracle 10g Database Administrator: Implementation and Administration

Statistics Object statistics System statistics Generally, object statistics record the number of rows in tables and the physical size of data Allows optimizer to have a realistic picture of data You can create a histogram for a table column where the distribution of values is skewed System statistics Whenever an event occurs it gets added to the sum for that event already recorded System statistics also store wait events A wait event that harms performance is a performance bottleneck Oracle 10g Database Administrator: Implementation and Administration

The Importance of Statistics Statistics are very important to how the optimizer assesses the best way to execute a query Statistics: computation or estimation of the exact size and placement of data in tables and indexes Used by optimizer to more effectively assess data in the database Can produce a better query plan and potentially provide a more accurate match of the data in the database Methods of gathering statistics in Oracle 10g: A manual method An automated process Oracle 10g Database Administrator: Implementation and Administration

Gathering Statistics Manually Statistics can be gathered manually using ANALYZE command Simple and easy to use DBMS_STATS package Recommended method (it is parallel executable) You can also manually gather statistics for snapshot comparison using STATSPACK Database Control Oracle 10g Database Administrator: Implementation and Administration

Using the ANALYZE Command ANALYZE { TABLE | INDEX } COMPUTE [ SYSTEM ] STATISTICS [ FOR ... object specifics ... ] ESTIMATE [ SYSTEM ] STATISTICS [ FOR ... object specifics ... ] [ SAMPLE n { ROWS | PERCENT } ] | DELETE [ SYSTEM ] STATISTICS; Examples: ANALYZE TABLE EMPLOYEE DELETE STATISTICS; ANALYZE TABLE EMPLOYEE COMPUTE STATISTICS; Oracle 10g Database Administrator: Implementation and Administration

Using the ANALYZE Command (continued) Oracle 10g Database Administrator: Implementation and Administration

Using the DBMS_STATS Package DBMS_STATS vs ANALYZE DBMS_STATS: Is more versatile and potentially faster Is a little more complex to use Has parallel execution, Oracle Partitioning benefits, and performance tuning capabilities Can be used to copy statistics between databases Can be used to gather stats at all object layers of a DB But, some non-optimizer statistics can only be gathered with ANALYZE To gather statistics for a single table: EXEC DBMS_STATS.GATHER_TABLE_STATS('<owner>', '<table>'); To gather statistics for a single index: EXEC DBMS_STATS.GATHER_INDEX_STATS('<owner>', '<index>'); Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics Gathering In Oracle 10g the default for statistics collection is automation Setting STATISTICS_LEVEL to TYPICAL or ALL If BASIC is used, stale statistics will not be monitored; they can give the optimizer an incorrect statistical picture of data in your database Automated statistics gathering in Oracle 10g is a great development Rule-based optimization is now obsolete There must be automation of statistical values Dynamic sampling (SAMPLE clause in queries) and CPU costing for optimizer is now more important Primary objective of automation is to avoid situations of stale or non-generated statistics Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics Gathering (continued) Automated statistics using GATHER_STATS_JOB Scheduler executes it daily (default), at default times Finds DB objects with missing or stale statistics, and generate those statistics for you Calls a DBMS_STATS procedure to generate stats To disable automated statistics gathering EXEC DBMS_SCHEDULER.DISABLE('GATHER_STATS_JOB'); Some DBs do not benefit from automation You can force manual statistics generation on specific objects using LOCK_TABLE_STATS and LOCK_SCHEMA_STATS Dynamic sampling can be a good substitute Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics Gathering (continued) Oracle 10g Database Administrator: Implementation and Administration

Dynamic Sampling If statistics are out of date or not present, then dynamic sampling may be used Dynamic sampling reads a small number of blocks in a table to make a best guess at the statistical picture of data in a table Dynamic sampling settings: OPTIMIZER_DYNAMIC_SAMPLING = 1 OPTIMIZER_DYNAMIC_SAMPLING = 2 OPTIMIZER_DYNAMIC_SAMPLING > 2 You should leave the setting at its default level of 2, unless you have a very good reason Oracle 10g Database Administrator: Implementation and Administration

The SAMPLE Clause SAMPLE clause is not really a part of automation It can be used as a substitute semi-automated statistical generator SAMPLE is added to the FROM clause of a query as a part of a SELECT statement Causes the reading of a percentage of rows or blocks, in order to gather a statistical picture of data Picture is passed to optimizer allowing a better cost-based guess at how data should be accessed Syntax: SELECT * FROM <table> SAMPLE(n) ... Will read a sample of n% of the rows in table, when generating a query plan for reading table in a query Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control Much of automation process is about automatic SQL tuning Optimizer can be switched from normal to tuning mode Tuning mode can consume large amounts of resources; intended for complicated and long-running queries only Automated SQL tuning can be performed manually using commands executed from within SQL*Plus but it is recommended to use only the Database Control Parts: The AWR, the ADDM, automatic SQL Tuning, and SQL Access Advisor Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) AWR executes statistical snapshots of the DB A snapshot takes a mathematical picture of the state of a database at a specific point in time The AWR can be found in the Database Control Statistics gathered by the AWR are as follows: Object statistics Active Session History (ASH) High impact SQL System statistics Time model system statistics Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) The ADDM uses snapshots taken by the AWR, to make statistical comparisons and reports Uses multiple snapshots taken by the AWR, and then performs an analysis between two snapshots Common issues that the ADDM is searching for: Over extended use of CPU time Sizing of memory structures Heavy I/O usage High consumption SQL statements Configuration issues Anything busy Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) Oracle 10g Database Administrator: Implementation and Administration

Automated Statistics and the Database Control (continued) Oracle 10g Database Administrator: Implementation and Administration

Performance Metrics A metric in Oracle Database is a special type of statistic, defined as a measure of a rate of change on a cumulative statistic A metric is a measure of a rate of change Metrics can be found in many of the V$ performance views Easiest way to access performance metrics is to administer and analyze them using the Database Control Oracle 10g Database Administrator: Implementation and Administration

Performance Metrics (continued) Oracle 10g Database Administrator: Implementation and Administration

Changing Performance Metric Parameters Oracle 10g Database Administrator: Implementation and Administration

Searching for Invalidated Objects Two ways to find invalid objects in Oracle 10g: Use the USER_OBJECTS metadata view and check the STATUS column (ALL_OBJECTS and DBA_OBJECTS can also be used) The metrics contained within the Database Control for finding invalid objects Oracle 10g Database Administrator: Implementation and Administration

Searching for Invalidated Objects (continued) Oracle 10g Database Administrator: Implementation and Administration

Lock Conflicts A share lock partially locks data where there is still partial access allowed to data by other sessions An exclusive lock completely prohibits changes to data, but still allows read access Locking of transactions and tables (using transactional control commands or LOCK TABLE) create locking situations manually In this chapter you examine how locks can occur as a result of Oracle 10g internally creating locks If too many people access the same data at once, then some form of internal locking will result Oracle 10g uses row locks (not escalating locks) Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts Two ways to detect locks The more difficult method is to use the V$ performance views and the Oracle Wait Event Interface, using V$ performance views The better way is to use the Database Control Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts (continued) Use the exercise on pages 623-626 to show how to detect lock conflicts using the Database Control. Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

How to Detect Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

Resolving Lock Conflicts Avoid building code/applications that cause locks Some locking is inevitable, especially in busy, highly concurrent OLTP databases In general you should not be resolving application-caused lock conflicts manually Lock conflicts that require manual resolution are usually caused in error Other problems are caused by DML commands that are not committed or rolled back, using LOCK TABLE, changing all rows in a busy table, etc. Altering tables in a production database is always risky and should be avoided if possible Oracle 10g Database Administrator: Implementation and Administration

Resolving Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

Resolving Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

Resolving Lock Conflicts (continued) Oracle 10g Database Administrator: Implementation and Administration

What is a Deadlock? Deadlock: one thing is waiting for another, but that other thing is also waiting for something A pending lock request cannot be serviced, because the lock required will never be released Can cause serious performance issues Most common cause is manual locking of data using LOCK TABLE or the FOR UPDATE clause Usually deadlocked sessions must be rolled back manually Ways of resolving a deadlock manually are: Rollback one of the deadlocked transactions Kill one of the sessions executing one of the deadlocked transactions Oracle 10g Database Administrator: Implementation and Administration

Summary Performance: speed at which database services its users and applications Performance monitoring can be manually performed by database administrators or by software Tools: EXPLAIN PLAN, SQL*Plus Autotrace, SQL Trace with TKPROF, STATSPACK, V$ performance views, the Wait Event Interface, and Database Control Database Control contains performance metrics for all sorts of performance issues Statistics give optimizer mathematical picture of data Gathered using ANALYZE and DBMS_STATS package, or with Database Control (AWR and ADDM) Augment automated statistics with dynamic sampling and using the SAMPLE BLOCK clause Oracle 10g Database Administrator: Implementation and Administration

Summary (continued) Performance metrics operate against thresholds When threshold is exceeded, a warning is sent to the Database Control main screen Performance metrics can be altered in Database Control You can search for invalidated object using USER_OBJECTS, DBA_OBJECTS, ALL_OBJECTS Or, use the Database Control Locks can be both explicit and implicit Explicit lock: when administrator issues LOCK TABLE Implicit locks: occur when there’s too much competition for the same data; can be shared or exclusive Oracle 10g Database Administrator: Implementation and Administration