1 Optimizing Your Database Performance the Easy Way by Diane Beeler, Consulting Product Marketing Manager, BMC Software and Igy Rodriguez, Technical Product Manager, BMC Software Customers and managers of the companies who serve them demand instant, fast access to information. This means that the database administrators (DBAs) who are responsible for this information must optimize the performance and availability of databases and anticipate and head off bottlenecks before they happen. These DBAs must be familiar with multiple database platforms, operating systems, and hardware platforms with little to no training. Maintaining database performance and availability is a challenging task. There are many events that can impact database performance. Once these events occur, it is important to diagnose and resolve these issues quickly and easily. Most importantly, it is important to be proactive and notify the DBAs before these events actually occur and impact the user experience. How do DBAs normally handle performance problems? Let s take a look. Manual Optimization of Database Performance One of the most common reasons for poor database performance is un-tuned SQL. There are many rules and guidelines that need to be followed when queries are being written. If these rules are not followed, performance issues will be impacted. Some of these rules are as follows: If statement(s) use the NOT IN operator, rewrite them with NOT EXISTS Compose Predicates Using AND and =. Use equijoins. Avoid a full-table scan if it is more efficient to get the required rows through an index. Avoid using an index that fetches 10,000 rows from the driving table if you could instead use another index that fetches 100 rows and choose selective indexes. Choose the join order so you will join fewer rows to tables later in the join order. Set up the driving table to be the one containing the filter condition that eliminates the highest percentage of the table. Use untransformed column values. Do not use SQL functions in predicate clauses or WHERE clauses. Use functionbased indexes where possible. Avoid mixed-type expressions. When using IN and NOT IN with a subquery, try to rewrite it with WHERE (NOT) EXISTS as an alternative. Minimize the use of DISTINCT. Do not use inequality operators such as <>, =!.
2 Do not use IS NULL and IS NOT NULL. These rules can take the DBA anywhere from a couple of minutes to several hours each to analyze the SQL when it is done manually. When a SQL performance issue occurs in production, the DBA or developer attempting to address the issue does the following: Checks the SQL to make sure the rules listed above are being followed. Possibly rewrites the query. Re-runs EXPLAIN PLAN to see if a better access path is selected. Typical Manual Tuning Steps Here are the typical steps a DBA follows to tune SQL manually once he knows there are performance problems: 1. Locate the problem queries. 2. Run EXPLAIN PLAN. 3. Interpret the output. What is the operation order? Look at the full table scans. Look at join operations. 4. Look at the indexes. Are there too many? Are there any not being used? Is there no index? 5. Rewrite the query. 6. Run EXPLAIN PLAN. 7. Interpret the output. What is the operation order? Look at the full table scans. Look at join operations. 8. Compare with the previous EXPLAIN PLAN(s). 9. Is it better? If not, repeat all of the steps again. This process can take a while, depending on the tuning experience of the DBA or developer. To get the best performance, he would have to manually rewrite a query several different ways, run the query, and then write down statistics on how fast it ran. Did it improve? Did it improve enough? Was it fast enough? The DBA can spend many hours in trying to tune the SQL, and in the end, discover that it was an application design issue, not a SQL problem. There are issues that go beyond rewriting a query. EXPLAIN PLAN can show that the query is using the indexes that it is supposed to, but the performance is still bad. The potential cause could be unbalanced indexes, which can greatly impact query performance. If there are a large number of deletes on their associated tables, there will be unbalanced indexes. These indexes need to be rebuilt on a regular basis.
3 Using Proactive and Diagnostic Tools to Optimize Database Performance Some of the events that can impact database performance and availability are database configuration parameters, migrated rows, resource contention, and most important, untuned queries. Two types of tools are needed in order to ensure acceptable levels of performance and availability proactive and diagnostic. The proactive tools alert DBAs to problems that are getting close to unacceptable levels, and the diagnostic tools analyze and pinpoint problem areas and provide advice as to how to resolve issues. With the right tools, DBAs can substantially increase the performance and availability of their databases. BMC Software has several expert DBA tools that have built-in intelligence and automation. These tools can advise the DBA and make it easier for him to be effective and efficient. BMC Expert DBA Tools for Performance Optimization DBXray for Oracle DBXray is the personal productivity tool that allows database professionals of all experience levels to manage and master the everyday challenges of database administration from any PC with a common Internet browser simply, quickly and effectively. DBXray: Improves the performance and prevents outages of a database by identifying and eliminating database bottlenecks Delivers ready access from anywhere, anytime through a Web browser Provides detailed drilldown information on user session details, 24-hour database view, 10 data files with highest I/O hits, 4 top memory consumers, space management, delays caused by redo log space requests, locks blocking other sessions, transactions that must wait on a rollback segment for completion, waits and latches, and many other critical metrics Includes SmartDBA Cockpit for access even remotely via the Web to Oracle, DB2 UDB, and Microsoft SQL Server databases from one single console. DBXray, Space Expert, and SQL-Explorer plug in to SmartDBA Cockpit and the user can access them from this one single interface.
4 Space Expert for Oracle Space Expert for Oracle can analyze a database, predict problems, and help a DBA fix them before they even happen. It provides information on when a reorganization is needed and can even do the reorg online. Space Expert: Reorganizes 24/7 databases online, without downtime, providing complete read and write access to database applications Avoids unplanned outages by identifying objects that have high severity problems and provides recommended actions Reduces the need for future reorganizations by performing powerful analysis of object condition, producing ideal settings that restore the object to peak performance Performs automated sophisticated scheduling, object selection, multi-processing, and full checkpoint restart capability Includes SmartDBA Cockpit and DBXray SQL-Explorer for Oracle SQL-Explorer offers the most advanced SQL tuning technology in the industry, allowing DBAs to improve business application performance by proactively analyzing, diagnosing, managing and tuning databases and applications offline while preserving application and business availability. It lets DBAs collect data nonintrusively, analyze SQL statements, optimize a database, and do what-if analysis with exclusive simulation technology without impacting your production environment. SQL-Explorer: Prevents production interruption by using a non-intrusive high-speed data collector for capturing and saving SQL for later analysis Extends DBA resources and improves application performance by automatically providing expert tuning recommendations Reduces tuning time by displaying all relevant tuning information in an intuitive format Tunes SQL before releasing application Optimizes SQL that is tuned Provides indexing suggestions based on SQL execution
5 Includes SmartDBA Cockpit and DBXray Typical Tuning Steps Using DBXray, Space Expert, and SQL-Explorer When the DBA uses no tool, he typically does not know there are performance problems until after they have already occurred. With DBXray, he can instantly spot a performance problem on the database-at-a-glance screen. He can also be proactive and head off performance problems with the information provided in the monitors on the DBXray screen. Once he figures out that he has performance problems or that he will have performance problems if he doesn t take action now he can use SQL-Explorer and Space Expert to optimize the performance of his database. Here are the steps a DBA follows to tune SQL using SQL-Explorer and Space Expert. 1. Use SQL-Explorer which automatically and quickly: Identifies queries that are affecting the performance of the database Gathers history via the High Speed Data Collector with very low overhead Runs EXPLAIN PLAN Displays several suggested query rewrites and a plain English explanation of execution steps Provides table definitions and defines indexes Uses simulation technology to run trials on a Virtual Instance to compare execution statistics No impact to production Great for long running queries Identifies the best query to use Compares EXPLAIN PLAN of the re-written SQL with the original SQL and color codes the differences 2. Use Space Expert to determine if indexes are selective or not and whether the indexes need to be rebuilt. Locate problem queries with SQL-Explorer Vendor Applications When using vendor applications like SAP, Siebel, and Oracle Financials, the SQL in the application cannot be modified. However, major performance gains can be achieved by using SQL-Explorer to analyze index usage and create indexes based on specific usage patterns in your database. SQL-Explorer can also be used to identify poorly written SQL in these applications. Even though you can t change the SQL from SQL-Explorer due to the restrictions in those applications, you can use SQL-Explorer to identify problem SQL and then the application vendors can fix it. Check selectivity of indexes and view index statistics with Space Expert
6 Customer Case BMC has a customer that was experiencing performance issues at specific times during the day. The DBA was running scripts to attempt to capture the problematic SQL. After several days of trying to do this manually, the DBA was not able to find the issue. Then DBXray, SQL-Explorer, and Space Expert were brought in to the picture. First he monitored user sessions with DBXray and noticed that there was a connection that was performing a great deal of physical I/O. He selected that session to view the SQL that was being executed, and selected the TUNE button. This took the SQL statement that was being executed by the session and pushed it to SQL-Explorer. The query was using NOT IN with a subquery. The subquery was not making use of available indexes. SQL-Explorer created a rewrite of the query. To see how the rewrites improved performance, he then selected the SQL statistics option from SQL- Explorer. When looking at the number of rows in the tables, he should have seen a greater improvement. More analysis was needed. Next a Find Problems job from Space Expert was executed. Much to his surprise, several indexes had experienced many deletes. The two indexes that were listed were ones that were needed to satisfy the query. Space Expert rebuilt the index and he ran the trials again. The query response time was dramatically improved by 85% - 100%. This is an interesting case where one layer of problems was peeled back and then another layer was exposed. An entry-level DBA with no tuning experience might struggle manually with the above problem for several days. An entry-level DBA could use DBXray, SQL-Explorer, and Space Expert and solve the problem in less than an hour. To solve the problem in such a short time, the DBA followed these steps: 1. He noticed the problem in DBXray with the User Sessions Drilldown information. A lot of physical I/O indicates that there are some untuned not optimized SQL statements and this indicates to use SQL-Explorer. SQL-Explorer automatically considers all of the rules in optimizing a query and gives the DBA several different rewrites of the SQL statement. 2. The DBA used SQL-Explorer and ran the Get Actual SQL Stats. It showed all of the possible rewrites, the elapsed time it took to run, the number of buffer gets, CPU time, physical reads, and number of rows fetched. It put a green check mark next to the statement that had the best statistics of the rewrites. There were very large tables in this example. The DBA saw some improvement with the rewritten statement, but should have seen a great improvement by the rewrite that SQL-Explorer generated. It added a WHERE clause to the subquery, thereby making use of available indexes. The NOT IN was changed to a NOT EXIST (this is one of the above rules for creating a query) and this helped improve performance even further. NOT IN can suppress indexes even when they are there so now he has ensured that that is not a problem. At this point, some DBAs might give up and might say that they tuned the SQL statements to be as fast as possible. There could still be object-related issues
7 affecting performance such as fragmented tablespaces, migrated rows, and indexes that needed rebuilding. 3. With the click of a mouse button, the DBA moved over to Space Expert and ran Find Problems and discovered the index problem. Space Expert rebuilt the index. He ran the now optimized query and realized an 85% - 100% improvement in performance over the original query! Conclusion DBAs can ease their workloads and ensure that their databases are available and tweaked for top performance by using DBXray, Space Expert, and SQL-Explorer intelligent, automated, integrated DBA tools. Not only do these tools make DBAs jobs easier, they also dramatically cut the time to solve and prevent performance problems, and they ensure that their databases are available and operating at peak performance. For more information on BMC s database products, visit BMC Software on the Web at BMC Software, Inc. [NYSE: BMC], is the leading provider of enterprise management solutions. Through its Assuring Business Availability approach, BMC Software delivers control over infrastructure management costs, control of market advantage and differentiation via service management, and growth of business value with solutions for business optimization. BMC Software is a member of the S&P 500, with fiscal year 2001 revenues exceeding $1.5 billion and offices worldwide. BMC Software, the BMC Software logos and all other BMC Software product or service names are registered trademarks or trademarks of BMC Software, Inc. All other registered trademarks or trademarks belong to their respective companies. 2002, BMC Software, Inc. All rights reserved /02
HP Performance Engineering Best Practices Series for Performance Engineers and Managers Performance Monitoring Best Practices Document Release Date: 201 Software Release Date: 2014 Legal Notices Warranty
HP Performance Engineering Best Practices Series for Performance Engineers and Managers Performance Monitoring Best Practices Document Release Date: May 2009 Software Release Date: May 2009 Legal Notices
Front cover End to End Performance Management on IBM i Understand the cycle of Performance Management Maximize performance using the new graphical interface on V6.1 Learn tips and best practices Hernando
Choosing a Monitoring System for Your IT Infrastructure? What Should Your Key Considerations Be? Introduction This document is intended for those considering to purchase monitoring software to maintain
John Inverso Technology Overview 10 November 2000 Help Desk Systems and Software: Overview Summary The help desk can be both a boon and a burden to a company, either increasing customer satisfaction and
Monitoring and Diagnosing Applications with 4.0 Mark W. Johnson IBM Corporation The (Application Response Measurement) standard provides a way to manage business transactions. By embedding simple calls
Borland StarTeam 2009 StarTeam Server Help Borland Software Corporation 8310 N Capital of Texas Hwy, Bldg 2, Ste 100 Austin, Texas 78731 USA www.borland.com Borland Software Corporation may have patents
Simplify VoIP Network Setup and Troubleshooting with NetTool VoIP Introduction As businesses search for new ways to cut costs and increase efficiency, they are moving their phone systems to VoIP (voice
WHITE PAPER Introduction... 2 Reduce Tool and Process Sprawl... 2 Control Virtual Server Sprawl... 3 Effectively Manage Network Stress... 4 Reliably Deliver Application Services... 5 Comprehensively Manage
SQL Server Data Warehouse Fast Track for Tegile 20 TB Certified Data Warehouse Reference Architecture Installation and Configuration Guide 5U Design: Featuring Tegile Zebi HA2400 Storage Array November
Capacity Planning DISCIPLINE FOR DATA CENTER DECISIONS TQ-EB01 Rev. A Copyright 2004 TeamQuest Corporation All Rights Reserved Like what you see? Subscribe. Table of Contents 1 Introduction...1-1 2 The
SYMANTEC ServiceDesk Customization Guide 7.0 Symantec ServiceDesk 7 The software described in this book is furnished under a license agreement and may be used only in accordance with the terms of the agreement.
MOVING THE DATA CENTER FROM CHAOS TO CONTROL BEST PRACTICES IN DATA CENTER INFRASTRUCTURE MANAGEMENT WITH INTEGRATED PROCESSES AND TECHNOLOGIES WHITE PAPER 101 TABLE OF CONTENTS 01 EXECUTIVE SUMMARY 03
Getting Started with New Relic: A Newbie s Table of Contents INTRODUCTION: Hello There, Newbie CHAPTER 1: Application Monitoring Overview CHAPTER 2: Real User Monitoring (RUM) CHAPTER 3: Transaction Traces
An Oracle White Paper April 2010 Application Performance Management with Oracle Enterprise Manager 11g Introduction... 1 Top Challenges of Application Performance Management... 2 Oracle s Application Performance
The Red Gate Guide SQL Server Backup and Restore Shawn McGehee ISBN: 978-1-906434-74-8 SQL Server Backup and Restore By Shawn McGehee First published by Simple Talk Publishing April 2012 Copyright April
Best Practices for Deploying and Managing Linux with Red Hat Network Abstract This technical whitepaper provides a best practices overview for companies deploying and managing their open source environment
Expert Oracle9i Database Administration SAM R. ALAPATI Expert Oracle9i Database Administration Copyright 2003 by Sam R. Alapati All rights reserved. No part of this work may be reproduced or transmitted
Kaseya Performance And Best Practices Guide Authors: Jacques Eagle Date: Thursday, April 29, 2010 1 P a g e Contents Introduction... 5 B.0 - The Basics... 6 B.1 - Hot Fixes... 6 B.2 64 bit versus 32 bit
Best Practices for DB2 on z/os Backup and Recovery Susan Lawson and Dan Luksetich www.db2expert.com and BMC Software June 2009 www.bmc.com Contacting BMC Software You can access the BMC Software website
White Paper White Paper Microsoft SQL Server Best Practices with Data Domain Deduplication Storage Abstract Users are faced with many options and tradeoffs when choosing a backup strategy for Microsoft
Achieving Business Performance Goals through Virtualization Management Best Practices An ENTERPRISE MANAGEMENT ASSOCIATES (EMA ) White Paper Prepared for eg Innovations, Inc Virtual environments need comprehensive
Building A Better Network Monitoring System A report submitted in fulfillment of the requirements for the degree of Bachelor of Computing and Mathematical Sciences with Honours at The University of Waikato
Product Documentation ER/Studio Repository Installation and Administration Guide 4th Edition Version 6.0 Published January 2011 2011 Embarcadero Technologies, Inc. Embarcadero, the Embarcadero Technologies