13.07.2015 Views

Automatic Performance Diagnosis and Tuning in Oracle

Automatic Performance Diagnosis and Tuning in Oracle

Automatic Performance Diagnosis and Tuning in Oracle

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Automatic</strong> <strong>Performance</strong> <strong>Diagnosis</strong> <strong>and</strong> <strong>Tun<strong>in</strong>g</strong> <strong>in</strong> <strong>Oracle</strong>Karl Dias, Mark Ramacher, Uri Shaft, Venkateshwaran Venkataramani, Graham Wood<strong>Oracle</strong> Corporation500 <strong>Oracle</strong> ParkwayRedwood Shores, CA 94065, USA{kdias, mramache, ushaft, veeve, gwood}@oracle.comAbstract<strong>Performance</strong> tun<strong>in</strong>g <strong>in</strong> modern database systemsrequires a lot of expertise, is very timeconsum<strong>in</strong>g <strong>and</strong> often misdirected. <strong>Tun<strong>in</strong>g</strong>attempts often lack a methodology that has aholistic view of the database. The absence ofhistorical diagnostic <strong>in</strong>formation to <strong>in</strong>vestigateperformance issues at first occurrenceexacerbates the whole tun<strong>in</strong>g process oftenrequir<strong>in</strong>g that problems be reproduced beforethey can be correctly diagnosed.In this paper we describe how <strong>Oracle</strong>overcomes these challenges <strong>and</strong> provides a wayto perform automatic performance diagnosis <strong>and</strong>tun<strong>in</strong>g. We def<strong>in</strong>e a new measure called‘Database Time’ that provides a commoncurrency to gauge the performance impact of anyresource or activity <strong>in</strong> the database. We expla<strong>in</strong>how the <strong>Automatic</strong> Database Diagnostic Monitor(ADDM) automatically diagnoses thebottlenecks affect<strong>in</strong>g the total databasethroughput <strong>and</strong> provides actionablerecommendations to alleviate them. We alsodescribe the types of performance measurementsthat are required to perform an ADDM analysis.F<strong>in</strong>ally we show how ADDM plays a central rolewith<strong>in</strong> <strong>Oracle</strong> 10g’s manageability framework toself-manage a database <strong>and</strong> provide acomprehensive tun<strong>in</strong>g solution.1. IntroductionWith the advent of web bus<strong>in</strong>ess, system performance ismore important to bus<strong>in</strong>esses than ever before. A poorlyperform<strong>in</strong>g web site is just as bad as one that is actuallyPermission to copy without fee all or part of this material is grantedprovided that the copies are not made or distributed for directcommercial advantage, the VLDB copyright notice <strong>and</strong> the title of thepublication <strong>and</strong> its date appear, <strong>and</strong> notice is given that copy<strong>in</strong>g is bypermission of the Very Large Data Base Endowment. To copyotherwise, or to republish, requires a fee <strong>and</strong>/or special permission fromthe EndowmentProceed<strong>in</strong>gs of the 2005 CIDR Conference.down, because users get frustrated <strong>and</strong> are unlikely toreturn. Databases are an <strong>in</strong>tegral part of these high profilesystems. With the decreas<strong>in</strong>g costs of computer hardware,bus<strong>in</strong>esses are build<strong>in</strong>g more <strong>and</strong> bigger databases, <strong>and</strong>the database adm<strong>in</strong>istrators (DBAs) are be<strong>in</strong>g asked totake on more <strong>and</strong> larger databases.Database systems typically have a plethora ofmeasurements <strong>and</strong> statistics available about theiroperation. Often many <strong>in</strong>dividual components ma<strong>in</strong>ta<strong>in</strong>separate sets of measurements <strong>and</strong> it can be hard to get anoverall view of what is happen<strong>in</strong>g <strong>in</strong> the database. Themany sets of measurements can lead to data overload forthe DBA who is tasked with analys<strong>in</strong>g a problem.Identification of the root cause of a performanceproblem is not easy [WE02, CH00, HE97, BR94]. It isnot uncommon for DBAs to spend large amounts of time<strong>and</strong> resources fix<strong>in</strong>g performance symptoms, only to f<strong>in</strong>dthat this had marg<strong>in</strong>al effect on system performance.Often a symptom is treated ma<strong>in</strong>ly because the DBA hasseen that symptom before <strong>and</strong> knows how to treat it. Lackof a holistic view of the database leads to <strong>in</strong>correctdiagnosis <strong>and</strong> misdirected tun<strong>in</strong>g efforts result<strong>in</strong>g <strong>in</strong> overconfiguredsystems <strong>in</strong>creas<strong>in</strong>g the total cost of ownership[HU02, CH00, GA96].Even when ‘correct’ analysis is performed it is oftenfound that the available data stops short of what isrequired to fully diagnose the root cause of the problem<strong>and</strong> <strong>in</strong> order to complete the diagnosis the problem mustbe reproduced. Reproduc<strong>in</strong>g problems is sometimes nontrivial<strong>and</strong> can range from simply ask<strong>in</strong>g a user to performan operation aga<strong>in</strong>, to requir<strong>in</strong>g the build<strong>in</strong>g of a copy ofthe database, which may take weeks to set-up. Manytimes performance issues go unresolved because it is notregarded as cost effective to spend the time <strong>and</strong> resourcesto reproduce the problem. Often, the issue is dropped <strong>and</strong>the DBA hopes that the problem will not reoccur. In mostcases, the mechanisms provided to capture detailed<strong>in</strong>formation required to be able to fully analyse a problemare not designed to be non-<strong>in</strong>trusive <strong>and</strong> have a significantoverhead. Sometimes tun<strong>in</strong>g experts or ‘gurus’ are called<strong>in</strong> to try <strong>and</strong> resolve a problem. Specialist skills <strong>and</strong>expertise are required because there are many areas wherevalue judgments <strong>and</strong> rules-of-thumb are <strong>in</strong>volved.


One of the th<strong>in</strong>gs that makes performance tun<strong>in</strong>gdifficult is that the performance of different componentsof the database is often measured us<strong>in</strong>g unrelated metricslike buffer hit-ratio, transactions per second <strong>and</strong> averageI/O latency. Such unrelated metrics make it <strong>in</strong>feasible toweigh the performance impact of one component of thedatabase with the impact of others components. <strong>Tun<strong>in</strong>g</strong>actions that are solely based on such metrics have atendency either to make the DBAs believe that thedatabase needs excessive hardware or to make just onecomponent of the database perform better with negligibleeffect on the total database throughput.Keep<strong>in</strong>g these limitations <strong>in</strong> m<strong>in</strong>d, we built the<strong>Automatic</strong> Database Diagnostic Monitor (ADDM) <strong>in</strong><strong>Oracle</strong> 10g. ADDM automates the entire process ofdiagnos<strong>in</strong>g performance issues <strong>and</strong> suggests relevanttun<strong>in</strong>g recommendations with the primary objective ofmaximiz<strong>in</strong>g the total database throughput.Modern database systems have complicated<strong>in</strong>teractions between their sub-components <strong>and</strong> have theability to work with a variety of applications. This results<strong>in</strong> a very large list of potential performance issues suchautomatic diagnosis solutions could identify. Also, as newdatabase technologies <strong>and</strong> applications are <strong>in</strong>vented <strong>and</strong>older ones are obsoleted, it is pivotal that automaticdiagnostic <strong>and</strong> tun<strong>in</strong>g solutions can easily be adapted toaccommodate such changes.The objectives of an automatic performance diagnosis<strong>and</strong> tun<strong>in</strong>g solution can be summarized as follows:• Should posses a holistic view of the database <strong>and</strong>underst<strong>and</strong> the <strong>in</strong>teractions between variousdatabase components.• Should be capable of dist<strong>in</strong>guish<strong>in</strong>g symptomsfrom the actual root-cause of performancebottlenecks.• Should provide mechanisms to diagnoseperformance issues on their first occurrence.• Should easily keep up with chang<strong>in</strong>gtechnologies.The rema<strong>in</strong>der of the paper is organized as follows:We discuss related work <strong>in</strong> both academic research <strong>and</strong>commercially available databases <strong>in</strong> Section 2. We def<strong>in</strong>ea new measure, Database Time, <strong>and</strong> describe <strong>in</strong> detail ourmethodology to solve this problem <strong>in</strong> Section 3. Wediscuss the various measurements that were required toimplement our solution <strong>in</strong> Section 4. We extend ourdef<strong>in</strong>ition of Database Time to other models <strong>in</strong> Section 5<strong>and</strong> expla<strong>in</strong> how ADDM plays a central role <strong>in</strong> <strong>Oracle</strong>10g’s self-manag<strong>in</strong>g framework <strong>in</strong> Section 6. We presentthe experiments we used to validate our implementation<strong>and</strong> their results <strong>in</strong> Section 7. F<strong>in</strong>ally, we summarize ourconclusions <strong>in</strong> Section 8.2. Related WorkThe COMFORT project used an onl<strong>in</strong>e feedback controlloop to solve <strong>in</strong>dividual tun<strong>in</strong>g issues like load control forlock<strong>in</strong>g, dynamic data placement among others [WE02,WE94]. Automated tun<strong>in</strong>g systems have been proposed[HE97] that employ a feedback control mechanismlayered on top of a target system. A different school ofthought suggests that current database systems have toomany features, unpredictable performance <strong>and</strong> very low“ga<strong>in</strong>/pa<strong>in</strong> ratio”, <strong>and</strong> RISC-type simplification ofdatabase functionality is crucial to achieve automatictun<strong>in</strong>g [WE02, CH00].<strong>Oracle</strong>’s previous solution for performance tun<strong>in</strong>g wasStatspack [ORP8, ORP9, ORSP]. Statspack is a tool thattakes snapshots of database performance statistics <strong>and</strong>generates reports across a pair of snapshots. ThoughStatspack reports reduced the time it took for DBAs todiagnose performance issues [ORSP2], it still left the<strong>in</strong>terpretation of the report <strong>and</strong> the actual root-causeidentification to the DBAs. <strong>Oracle</strong> 9i has other selfoptimiz<strong>in</strong>gfeatures like dynamic runtime queryoptimization [ORQ9], self-configur<strong>in</strong>g features for space<strong>and</strong> memory management [DA02, ORM9, EL03]. Referto Section 6 for a description of various <strong>Oracle</strong> 10g’smanageability features like “SQL <strong>Tun<strong>in</strong>g</strong> Advisor” <strong>and</strong>“Segment Advisor”. IBM DB2 version 8.1 has featureslike “Health Center” for database monitor<strong>in</strong>g <strong>and</strong>“Configuration Assistant” to assist DBAs <strong>in</strong> databaseconfiguration [IBP8, IBG8]. Similarly, SQL Server 2000provides performance tools like “Index <strong>Tun<strong>in</strong>g</strong> Wizard”<strong>and</strong> “SQL Query Analyzer” to help the DBA achieve<strong>in</strong>dividual performance goals <strong>and</strong> has monitor<strong>in</strong>g toolslike “System Monitor objects” [CH97, MSPD].Commercially available databases have features tomanage some of their sub-components automatically,mechanisms to actively monitor database performance,<strong>and</strong> tools that make it easier for the DBA to achieve somespecific performance goals. However, none of them (until<strong>Oracle</strong> 10g) have a performance diagnosis <strong>and</strong> tun<strong>in</strong>gsolution that automatically identifies the root-causesaffect<strong>in</strong>g total database throughput.3. <strong>Automatic</strong> <strong>Performance</strong> <strong>Diagnosis</strong><strong>Performance</strong> of various components of the database aremeasured us<strong>in</strong>g different metrics. For example, theefficiency of the data-block buffer cache is expressed as apercentage <strong>in</strong> buffer hit-ratio; the I/O subsystem ismeasured us<strong>in</strong>g average read <strong>and</strong> write latencies; thedatabase throughput is measured us<strong>in</strong>g transactions-persecond.However, us<strong>in</strong>g these metrics, f<strong>in</strong>d<strong>in</strong>g theperformance impact of a particular component over thetotal database throughput is extremely hard, if not<strong>in</strong>feasible. For example, determ<strong>in</strong><strong>in</strong>g by how much wouldtransactions-per-second decrease if the average I/Olatency becomes twice as long is not trivial.


User sendsa requestUser getsa responseWide area networkApplication ServerLocal area network<strong>Oracle</strong> DatabaseWall-clock timeTime spent <strong>in</strong> the Wide area networkTime spent <strong>in</strong> the Application Server (Middle Tier)Time spent <strong>in</strong> the Local area networkDatabase time spent process<strong>in</strong>g the user requestFigure 1: Database time from a s<strong>in</strong>gle user’s perspective.SessionconnectExecuteSQLExecuteSQLExecuteSQLFetchresult..FetchresultsFetchresultsExecuteSQLFetchresultsFetchresultsFetchresultFetchresultsFetchresultsExecuteSQLExecuteSQLSessiondisconnectFetchresultUser 1..User 2User nWall-clock timeDatabase time spent <strong>in</strong> process<strong>in</strong>g user requestsFigure 2: Database time def<strong>in</strong>ed as the sum of the time spent <strong>in</strong> process<strong>in</strong>g all user requestsOne of the first objectives of this project was to def<strong>in</strong>ea common currency that can be used to measure theperformance impact of any component with<strong>in</strong> thedatabase. It then becomes possible to be able to comparethe impact of any two database components. For example,one would then be able to compare the performanceimpact due to an under-sized data-block buffer cache withthe performance impact due to a badly written SQLstatement. For this purpose, we def<strong>in</strong>e a measure called‘Database Time’ that would serve as a common currency.3.1 Database TimeDatabase time is def<strong>in</strong>ed as the sum of the time spent<strong>in</strong>side the database process<strong>in</strong>g user requests. Figure 1illustrates a simple scenario of a s<strong>in</strong>gle user submitt<strong>in</strong>g arequest. User’s response time is the time <strong>in</strong>terval betweenthe <strong>in</strong>stant the request is sent <strong>and</strong> the <strong>in</strong>stant the responseis received. The database time <strong>in</strong>volved <strong>in</strong> that userrequest is only a portion of that user’s response time thatis spent <strong>in</strong>side the database.Figure 2 illustrates database time as it is summed overmultiple users <strong>and</strong> each user is perform<strong>in</strong>g a series ofoperations result<strong>in</strong>g <strong>in</strong> a series of requests to the database.It can be seen from Figure 2 that database time is directlyproportional to the number <strong>and</strong> duration of user requests<strong>and</strong> can be higher or lower than the correspond<strong>in</strong>g wallclocktime.Us<strong>in</strong>g database time as a measure, one should be ableto gauge the performance impact of any entity of thedatabase. For example, the performance impact of anunder-sized buffer cache would be measured as the totaldatabase time spent <strong>in</strong> perform<strong>in</strong>g additional I/O requeststhat could have been avoided if the buffer cache waslarger.


SessionconnectExecuteSQLExecuteSQLExecuteSQLFetchresultFetchresultsFetchresultsFetchresultsFetchresultsFetchresultsFetchresultsExecuteSQLSessiondisconnect. Execute FetchExecute Fetch..SQLresultSQL result .User 1User 2User nSample 1 Sample 2 Sample 3Sample 4 Sample 5Wall-clock timeA s<strong>in</strong>gle row <strong>in</strong> the Active Session History table shown belowSample UserNumber NumberOperation Details1 1 Connect Us<strong>in</strong>g CPU2 1 Execute Us<strong>in</strong>g CPU2 2 Execute Wait<strong>in</strong>g for read I/O of block 5 of Emp table3 n Execute Wait<strong>in</strong>g for lock on block 5 of Emp Table4 2 Fetch Us<strong>in</strong>g CPU4 n Execute Wait<strong>in</strong>g for CPUFigure 4: Active Session History Samplesnegligible <strong>in</strong> some cases, but could be prohibitive <strong>in</strong>others.In sections 4.2 to 4.5 we describe the different types ofdata we collect for ADDM analysis. In all cases wedescribe both the purpose of the data <strong>and</strong> how it conformsto the m<strong>in</strong>imal <strong>in</strong>trusion pr<strong>in</strong>ciple.4.2 Database Time MeasurementsThe first priority <strong>in</strong> an ADDM analysis is to establish thema<strong>in</strong> components that consume significant database time.The database server must be <strong>in</strong>strumented to measure theamount of database time spent <strong>in</strong> specific operationsADDM is <strong>in</strong>terested <strong>in</strong>. This measurement is a cumulativenon-decreas<strong>in</strong>g function of time. ADDM analysis isalways performed over a specific time <strong>in</strong>terval called the“analysis period” (e.g., yesterday between 10am <strong>and</strong>11am). ADDM f<strong>in</strong>ds how much time was spent on aspecific operation by subtract<strong>in</strong>g the measurement for thebeg<strong>in</strong>n<strong>in</strong>g of the analysis period from the measurementfor the end of the analysis period.We ma<strong>in</strong>ta<strong>in</strong> measurements at various granularities soan ADDM analysis can go from the symptoms (e.g.,commit operations consumed significant database time) tothe root cause (e.g., write I/O to one of the log files wasvery slow—possibly a hardware issue). We need toma<strong>in</strong>ta<strong>in</strong> measurements at the coarse level—time spent <strong>in</strong>all commit operations. We also need the f<strong>in</strong>ergranularity—time spent <strong>in</strong> write I/O for each log file.Direct measurements can only be done on databaseoperations that usually take significant time to f<strong>in</strong>ish. Ifwe try to measure the tim<strong>in</strong>g of numerous short operationswe are likely to violate the m<strong>in</strong>imal <strong>in</strong>trusion pr<strong>in</strong>ciple.The decision about which operations should be measuredshould be based on the cost of measurement (i.e., howmuch time it takes to start <strong>and</strong> end a timer) <strong>and</strong> theexpected length <strong>and</strong> quantity of such operations. Forexample, measur<strong>in</strong>g the total time spent <strong>in</strong> I/O operationsis reasonable because I/O operations take many orders ofmagnitude more time than start<strong>in</strong>g <strong>and</strong> end<strong>in</strong>g a timer. Onthe other h<strong>and</strong>, measur<strong>in</strong>g the time we spend <strong>in</strong> the criticalsection of a commonly used semaphore would beprohibitively expensive. Our solution to capture shortduration operations is to use sampl<strong>in</strong>g. We use bothfrequency based sampl<strong>in</strong>g, where we sample oneoperation out of every N occurrences, <strong>and</strong> time basedsampl<strong>in</strong>g which is discussed <strong>in</strong> detail <strong>in</strong> the next section.4.3 Active Session HistoryADDM often needs a detailed description of the workloadto be able to f<strong>in</strong>d root-causes of problems <strong>and</strong> give


effective recommendations. It is not possible to collect acomplete system trace of operations s<strong>in</strong>ce the amount ofdata is very large <strong>and</strong> it will significantly affect databaseperformance. Our solution is to provide a time basedsample of all activity <strong>in</strong> the system. We call this sampleddata the “Active Session History” (ASH).ASH is a collection of samples taken at regular time<strong>in</strong>tervals. Each sample conta<strong>in</strong>s <strong>in</strong>formation about whatthe database server is do<strong>in</strong>g on behalf of each connecteduser (a.k.a. “session”) at the time of sampl<strong>in</strong>g. We onlycollect data for sessions that are actively us<strong>in</strong>g thedatabase dur<strong>in</strong>g the sample time. If a session is wait<strong>in</strong>gfor the next user comm<strong>and</strong>, it does not appear <strong>in</strong> ASH forthe specific sample time.Figure 4 illustrates a workload <strong>and</strong> the table <strong>in</strong> thatfigure shows the result<strong>in</strong>g ASH samples. The samples <strong>in</strong>ASH describe the database operation performed by eachsession <strong>in</strong> great detail. For example, when a session iswait<strong>in</strong>g for I/O we can tell which database object is read,what portion of it is read. This amount of detail enablesADDM to drill down to very specific root-causes.The time <strong>in</strong>terval we use for ASH sampl<strong>in</strong>g should beat least two orders of magnitude shorter than the time<strong>in</strong>terval used as an analysis period. This ensures that wehave at least hundreds of samples of specific sessionstates to analyze. If a specific operation consumessignificant database time (say more than a few percents ofdatabase time) dur<strong>in</strong>g the analysis period, there is a highprobability that this operation will appear <strong>in</strong> a significantnumber of samples <strong>in</strong> ASH. This enables ADDM todiagnose such operations even if we do not measure themdirectly. The ASH sampl<strong>in</strong>g frequency should be chosenwith care. If sampl<strong>in</strong>g is too frequent, it might violate them<strong>in</strong>imal <strong>in</strong>trusion pr<strong>in</strong>ciple. If sampl<strong>in</strong>g is <strong>in</strong>frequent,ADDM may not be able to f<strong>in</strong>d the root-cause of aproblem or an effective recommendation, because theremay not be enough samples of the specific operation.ADDM uses ASH for f<strong>in</strong>d<strong>in</strong>g root-causes <strong>and</strong>effective recommendations. For example, suppose we f<strong>in</strong>dfrom exact database time measurements that the chiefsource of contention <strong>in</strong> the system is on locks that dealwith space allocation to tables. We can use ASH to f<strong>in</strong>df<strong>in</strong>er granularity of events like “which are the top tablesthat experienced space allocation contention <strong>and</strong> what arethe types of SQL statements used for such contention?”We might be able to determ<strong>in</strong>e that a specific table suffersfrom contention due to INSERT statements <strong>and</strong>recommend a partition<strong>in</strong>g scheme to alleviate theproblem. While time measurements might be able to leadus to the specific type of locks that cause a problem, orsometimes to the specific table, only ASH allows us toperform a cross analysis with the types of SQL statementsthat contended for the locks. Without ASH, ADDM couldnot recommend the specific solution: partition a specifictable.4.4 System ConfigurationWe also collect data that is not numeric <strong>in</strong> nature or thatcan decrease with time. This data is usually aboutdatabase sett<strong>in</strong>gs. We need to ma<strong>in</strong>ta<strong>in</strong> a full log ofchanges for this k<strong>in</strong>d of data. Fortunately, databasesett<strong>in</strong>gs do not change very often, so the cost ofma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g a full log of changes does not cost much. Thistype of data can be crucial to giv<strong>in</strong>g recommendations forfix<strong>in</strong>g specific problems. Examples of such data are:• Size of memory components (like buffer cache)• Number of CPUs used by the system.• Special query optimizer sett<strong>in</strong>gs.The exact nature of the data depends on theimplementation of the database server <strong>and</strong> is outside thescope of this paper.4.5 SimulationsSometimes, estimat<strong>in</strong>g the impact of a specific area of thedatabase requires a simulation of various possiblealternatives. For example, we might have significantimpact of read I/O operations because the buffer cache isunder-sized. The database time measurement is the timewe spent on read I/O operations. However, to f<strong>in</strong>d thatthe buffer cache is the root-cause we must determ<strong>in</strong>e thatwe spent time read<strong>in</strong>g data blocks that were <strong>in</strong> the buffercache at some po<strong>in</strong>t <strong>in</strong> time <strong>and</strong> were removed to makeroom for other data blocks. In other words, we need todeterm<strong>in</strong>e how many read I/O operations could have beensaved given an <strong>in</strong>f<strong>in</strong>ite buffer cache. Our solution is tosimulate how much database time would be saved whenthe buffer cache is <strong>in</strong>creased to various sizes <strong>and</strong>recommend an optimal sett<strong>in</strong>g given the resources.5. Database Time <strong>in</strong> Other ModelsThe def<strong>in</strong>ition of database time <strong>in</strong> Section 3.1 relies on asimple computation model. The model is characterizedby the follow<strong>in</strong>g limitations:• S<strong>in</strong>gle Mach<strong>in</strong>e. This means that we do not havea distributed system. Instead, we use a s<strong>in</strong>glehost mach<strong>in</strong>e for the database server.• No Background Activity. This means that alldatabase work is done while the user is wait<strong>in</strong>gfor a response.• No Parallel Computation. Every user connectioncorresponds to a s<strong>in</strong>gle thread of computation <strong>in</strong>the database server. This means that work doneon behalf of a user call cannot use more than oneCPU at the same time, wait for more than oneevent at the same time, or wait for an event <strong>and</strong>use a CPU at the same time.Most database servers support computation models thatuse distributed systems, parallel queries <strong>and</strong> backgroundactivity. Therefore, we needed to establish ADDM’s goalswhen each of these assumptions is violated.


5.1 Distributed SystemsThe simplest distributed system has identical components.This means that all the mach<strong>in</strong>es that are part of thesystem are identical mach<strong>in</strong>es, runn<strong>in</strong>g the same software,have the same network connections, <strong>and</strong> use the sametypes of I/O devices. In this simple case, all we need to dois sum the database time observed on all mach<strong>in</strong>es to getthe total database time for the distributed system. Everysubdivision of database time (e.g., the time spent wait<strong>in</strong>gfor I/O) is summed across all mach<strong>in</strong>es as well.It is a lot more complicated when there are differencesbetween mach<strong>in</strong>es. In that case we need to f<strong>in</strong>d a commoncurrency between mach<strong>in</strong>es <strong>and</strong> not just between differentareas <strong>in</strong> the same server. For example, we cannot considerone second of CPU usage on one mach<strong>in</strong>e equivalent toone second of CPU usage on another mach<strong>in</strong>es if the twoCPUs have different computation speeds. We still sum allthe database times from the different mach<strong>in</strong>es becausethis number still corresponds to the total amount timespent by users wait<strong>in</strong>g for a response from the databaseserver. We just need to consider that mov<strong>in</strong>g a thread ofcomputation from one mach<strong>in</strong>e to another may result <strong>in</strong>changes to the total database time. For example, mov<strong>in</strong>g aCPU heavy computation from a slow CPU to a fast CPUis go<strong>in</strong>g to reduce database time if the two mach<strong>in</strong>es arenot CPU bound both before <strong>and</strong> after the move.5.2 Background ActivityBackground activity is an important component <strong>in</strong> an<strong>Oracle</strong> server. For example, data blocks do not need to bewritten to disk even after a transaction commits. It isenough that the appropriate log records are written todisk. Therefore, most write I/O to tables <strong>and</strong> <strong>in</strong>dexes isdone as a background activity; no user waits for thesewrites to complete.We regard background activity as a set of threads ofcomputation. The time spent <strong>in</strong> these threads is notcounted <strong>in</strong> database time s<strong>in</strong>ce no user waits for thesethreads. However, statistics about resource usage by thebackground must be ma<strong>in</strong>ta<strong>in</strong>ed. When ADDM detectsthat a resource is used too much, a possiblerecommendation is to reduce the background activity thatuses the resource. For example, if the I/O sub-system isused so heavily that I/O response time is both very slow<strong>and</strong> responsible for most of the database time, we mightconsider reduc<strong>in</strong>g the frequency of checkpo<strong>in</strong>ts.5.3 Parallel ComputationThe first problem we have with parallel computation ishow to measure database time. Parallel computationimplies that a s<strong>in</strong>gle user connection is responsible formultiple threads of computation, which may use multipleCPUs <strong>and</strong> wait for multiple events or resources. S<strong>in</strong>cedatabase time is a measurement of throughput, we mustconsider all time spent by all the threads of computationas part of database time. The only exception is when onethread is wait<strong>in</strong>g for another thread that belongs to thesame user connection. In that case we consider the waittime as idle <strong>and</strong> we do not add it to database time. Thereason for this exception is that we try to gauge what thedatabase time would be if the computation were serializedwhile ma<strong>in</strong>ta<strong>in</strong><strong>in</strong>g the same execution plan. In that case,all CPU usage <strong>and</strong> waits for external resources are stillparts of the computation. However, <strong>in</strong>ternal wait betweenthreads disappears from the computation.Parallel computations are used when we need toreduce the response time of a request. As is always thecase with parallel algorithms throughput is sacrificed toget better response time. In many cases, the response timeof a specific user request is more important than the totalsystem throughput. ADDM advises the databaseadm<strong>in</strong>istrator how much extra database time is spent onparallel computations compared to serial computation. Inthis case we must consult the optimizer to f<strong>in</strong>d the bestserial execution plan <strong>and</strong> compare it to the parallelexecution plan that was actually used. This is a simulations<strong>in</strong>ce we do not execute the serial plan <strong>and</strong> do not knowthe exact cost <strong>in</strong> terms of database time.5.4 SummaryWe have seen how distributed systems, backgroundactivity <strong>and</strong> parallel queries can complicate both thenotion of database time <strong>and</strong> the goal of an ADDManalysis. These are not the only complications weencountered <strong>and</strong> solved when implement<strong>in</strong>g ADDM <strong>in</strong><strong>Oracle</strong> 10g. However, a complete list is outside the scopeof this paper. The general pr<strong>in</strong>ciple rema<strong>in</strong>s the same:f<strong>in</strong>d a common currency to measure database throughput,f<strong>in</strong>d ways to <strong>in</strong>crease that throughput <strong>and</strong> improve theperformance of the database as users experience it.6. ADDM’s Role <strong>in</strong> Self-Manag<strong>in</strong>gDatabasesADDM is a central part of the manageability frameworkfor self-manag<strong>in</strong>g a database that was developed <strong>in</strong> <strong>Oracle</strong>10g (see [ORM10]). This framework enables acomprehensive tun<strong>in</strong>g solution by provid<strong>in</strong>g the necessarycomponents. ADDM is a key component that serves asthe central <strong>in</strong>telligence for various tun<strong>in</strong>g activities <strong>in</strong> thesystem, like SQL <strong>Tun<strong>in</strong>g</strong> [ORQ10] or SpaceFragmentation Analysis [ORS10], s<strong>in</strong>ce it takes a holisticview of the database system <strong>and</strong> identifies the top issuesaffect<strong>in</strong>g overall throughput. ADDM itself relies on theframework to a large extent for ready access to theperformance measurements it needs.The manageability solution <strong>in</strong> <strong>Oracle</strong> 10g is centeredaround the three phases of the self-manag<strong>in</strong>g loop:Observe, Diagnose, <strong>and</strong> Resolve. Each componentprovided by the framework plays a key role <strong>in</strong> one ormore of these phases. These phases refer to a particularactivity (e.g.: a SQL tun<strong>in</strong>g cycle), <strong>and</strong> there could be


<strong>Automatic</strong><strong>Performance</strong><strong>Diagnosis</strong>ADDMmany such activities occurr<strong>in</strong>g concurrently each <strong>in</strong>different phases. Figure 5 <strong>and</strong> the subsequent sectionsbelow illustrate the relationship between the ma<strong>in</strong>components <strong>and</strong> how they <strong>in</strong>teract with ADDM.6.1 Observe PhaseAWRRecommendationsAuto SnapshotCollection<strong>Oracle</strong> 10gAdvisorsFigure 5: ADDM <strong>and</strong> the Self-Manag<strong>in</strong>gDatabase frameworkIn-memoryperf dataApply tosystemThis phase is automatic <strong>and</strong> cont<strong>in</strong>uous <strong>in</strong> <strong>Oracle</strong> 10g <strong>and</strong>provides the data needed for analysis <strong>and</strong> feedback as aresult of the actions taken as part of the analysis. Toenable accurate system performance monitor<strong>in</strong>g <strong>and</strong>tun<strong>in</strong>g it is imperative that the system under considerationexposes relevant measurements <strong>and</strong> statistics. Themanageability framework allows for <strong>in</strong>strumentation ofthe code to obta<strong>in</strong> precise tim<strong>in</strong>g <strong>in</strong>formation, <strong>and</strong>provides a lightweight comprehensive data collectionmechanism to store these measurements for furtheronl<strong>in</strong>e or offl<strong>in</strong>e analysis.The ma<strong>in</strong> component of this phase is the “<strong>Automatic</strong>Workload Repository” (AWR). It is a persistent store ofperformance data for <strong>Oracle</strong>10g. The database capturessystem <strong>and</strong> performance data from <strong>in</strong>-memory viewsevery hour <strong>and</strong> stores it <strong>in</strong> AWR. Each collection isreferred to as a snapshot. Any pair of snapshotsdeterm<strong>in</strong>es an analysis period that can be used for anADDM analysis. The AWR is self-manag<strong>in</strong>g; it acceptspolicies for data retention <strong>and</strong> proactively purges datashould it encounter space pressure.The snapshot mechanism along with thecomprehensive data it collects solves the “first occurrenceanalysis” requirement. ADDM runs automatically eachtime a snapshot is taken, the period of analysis be<strong>in</strong>gdef<strong>in</strong>ed by the two most recent consecutive snapshots.6.2 Diagnose PhaseThe activities <strong>in</strong> this phase refer to the analysis of variousparts of the database system us<strong>in</strong>g the data <strong>in</strong> AWR or <strong>in</strong>the <strong>in</strong>-memory views. <strong>Oracle</strong> 10g <strong>in</strong>troduces a set ofadvisors, ADDM be<strong>in</strong>g one of them, for analyz<strong>in</strong>g <strong>and</strong>optimiz<strong>in</strong>g the performance of its respective subcomponents.Of particular note is the fact that all theadvisors provide an impact <strong>in</strong> terms of Database Time forthe problems they diagnose. This allows for easycomparison across advisors’ results.ADDM consults these advisors dur<strong>in</strong>g its analysisdepend<strong>in</strong>g on the amount of time <strong>and</strong> resources needed bythese advisors. If an advisor could potentially take asubstantial amount of time for its analysis, ADDMgenerates a recommendation to <strong>in</strong>voke that specificadvisor <strong>in</strong>stead. The user can then schedule this task whenappropriate.The set of advisors that ADDM can <strong>in</strong>voke <strong>in</strong>clude• SQL <strong>Tun<strong>in</strong>g</strong> Advisor: tunes SQL statements byimprov<strong>in</strong>g the execution plan, by perform<strong>in</strong>gcost based access path analysis <strong>and</strong> SQLstructure analysis.• Segment Advisor: analyses space wastage byobjects due to <strong>in</strong>ternal <strong>and</strong> externalfragmentation.• Memory Advisors: cont<strong>in</strong>uously monitor thedatabase <strong>in</strong>stance <strong>and</strong> auto-tune the memoryutilization between the various memory pools.6.3 Resolve PhaseThe various advisors, after hav<strong>in</strong>g performed theiranalysis, provide as output a set of recommendations thatcan be implemented or applied to the database. Eachrecommendation is accompanied by a benefit, <strong>in</strong> databasetime, that the workload would experience should therecommendation be applied. The recommendations maybe automatically applied by the database (e.g., thememory resiz<strong>in</strong>g by the memory advisors) or it may be<strong>in</strong>itiated manually. This is the Resolve phase.Apply<strong>in</strong>g recommendations to the system close aniteration of that particular tun<strong>in</strong>g loop. The <strong>in</strong>fluence ofthe recommendations on the workload will then beobserved <strong>in</strong> future performance measurements. Furthertun<strong>in</strong>g loops may be <strong>in</strong>itiated until the desired level ofperformance is atta<strong>in</strong>ed.7. Experiments <strong>and</strong> ResultsIt is not an easy task to test <strong>and</strong> quantify the results ofADDM. The value of ADDM is <strong>in</strong> help<strong>in</strong>g DBAs managethe performance of their databases. Check<strong>in</strong>g if ADDMmeets the task, we need to survey many customers thatalready adapted <strong>Oracle</strong> 10g <strong>in</strong> a production or testenvironment. It is too early after the release of <strong>Oracle</strong>10g to perform such a survey. However, we provide threeexamples of real ADDM usage <strong>in</strong> Sections 7.1 to 7.3.


We used various scenarios to gauge the effectiveness ofADDM.Bl<strong>in</strong>d tests were performed <strong>in</strong> the <strong>in</strong>itial test<strong>in</strong>g phase;performance tun<strong>in</strong>g experts were asked to analyse <strong>and</strong>make recommendations on runn<strong>in</strong>g systems. In a majorityof cases ADDM produced comparable results <strong>and</strong> <strong>in</strong> somecases ADDM’s recommendations produced greaterbenefit than the experts’ recommendations.As part of the test<strong>in</strong>g performed <strong>in</strong>ternal to <strong>Oracle</strong>Server Technologies group we have a number of tests <strong>in</strong>which we <strong>in</strong>troduced known ‘common faults’ <strong>and</strong>application <strong>in</strong>efficiencies. When ADDM analysis wasperformed on the data captured dur<strong>in</strong>g these tests ADDMcorrectly identified the fault <strong>in</strong> all cases.High load stress test<strong>in</strong>g is an <strong>in</strong>tegral part of thetest<strong>in</strong>g of the database product at <strong>Oracle</strong> <strong>and</strong> the effect ofrunn<strong>in</strong>g all of the <strong>Oracle</strong> 10g manageability features wasmeasured. With both typical customer workloads <strong>and</strong>highly tuned <strong>in</strong>dustry st<strong>and</strong>ard benchmarks the reduction<strong>in</strong> throughput from enabl<strong>in</strong>g all of the manageabilityfeatures was approximately 3%. AWR <strong>and</strong> ADDM weretwo of the features enabled. ADDM runs performed aftereach AWR snapshot were available <strong>in</strong> a timely manner,typically under ten seconds.Although <strong>Oracle</strong> 10g was declared production <strong>in</strong>January 2004 a number of <strong>in</strong>ternal production systemswere runn<strong>in</strong>g the software for several months before thisdate. ADDM has identified <strong>and</strong> correctly diagnosed anumber of performance issues <strong>in</strong> this time on thesesystems.7.1 Experience of QualcommQualcomm Centauri Application was upgraded from<strong>Oracle</strong> version 8.1.7.4 to 10g RAC. While test<strong>in</strong>g theupgrade they found significant performance problems <strong>and</strong>testers reported poor response times. The DBA looked atthe ADDM recommendations which highlighted a SQL(update statement) that was caus<strong>in</strong>g over 90% of thesystem load. They then ran SQL <strong>Tun<strong>in</strong>g</strong> Advisor on thestatement <strong>and</strong> it recommended the creation of an <strong>in</strong>dex. Itwas later found that the recommended <strong>in</strong>dex should havebeen <strong>in</strong> place. The <strong>in</strong>dex was miss<strong>in</strong>g because a patch tothe application was applied to the production system butnot to the upgraded test system. Identify<strong>in</strong>g the <strong>in</strong>dexmade problem diagnosis easy.7.2 Experience <strong>in</strong> <strong>Oracle</strong>’s Bug DatabaseThe <strong>Oracle</strong> Bug database is used daily by many thous<strong>and</strong>sof users <strong>and</strong> was one of the first production systems tomove to <strong>Oracle</strong> 10g. The system runs on an 8 CPU PA-RISC HP mach<strong>in</strong>e. After upgrad<strong>in</strong>g to <strong>Oracle</strong> 10g usersexperienced poor performance. ADDM reported that userswere spend<strong>in</strong>g a large proportion of their time wait<strong>in</strong>g forfree buffer waits <strong>and</strong> recommended exam<strong>in</strong><strong>in</strong>g the I/Osubsystem for write performance (this type of problemhappens when the buffer cache is filled with dirty buffers<strong>and</strong> faster I/O should solve the problem). When theSystem Adm<strong>in</strong>istrator looked at the I/O subsystem hefound that the asynchronous I/O was <strong>in</strong>correctlyconfigured caus<strong>in</strong>g asynchronous I/O requests to fail <strong>and</strong>then be performed synchronously lead<strong>in</strong>g to extremelyslow IO times.7.3 Experience of <strong>Oracle</strong> Applications QA Test<strong>in</strong>gAn Applications Development DBA reported that a usersaid that the system was slow. Unfortunately there was notimescale or details given. Investigation was made harderby the fact that the users of the system <strong>and</strong> the DBAs<strong>in</strong>vestigat<strong>in</strong>g the slowdown where on opposite sides of theworld, 12 time zones apart.Look<strong>in</strong>g at ADDM reports there were a couple of onehour periods <strong>in</strong> which the time spent <strong>in</strong> the database wassignificantly higher. Both of these ADDM reports showedthat most of the time was spent <strong>in</strong> pars<strong>in</strong>g <strong>and</strong> that thepars<strong>in</strong>g was caused by the application generat<strong>in</strong>g largenumbers of SQL statements conta<strong>in</strong><strong>in</strong>g literal str<strong>in</strong>gvalues. (This problem is <strong>Oracle</strong>’s equivalent of us<strong>in</strong>gmany similar SQL statements <strong>in</strong>stead of a storedprocedure. The cost of such configurations is time spent<strong>in</strong> pars<strong>in</strong>g, optimiz<strong>in</strong>g <strong>and</strong> compil<strong>in</strong>g the SQL statements<strong>in</strong><strong>Oracle</strong>’s term<strong>in</strong>ology it is called “hard parse”). Therecommendation from ADDM was to modify theapplication to use b<strong>in</strong>d variables rather than literals or tochange a database configuration parameter toautomatically convert the literals <strong>in</strong>to b<strong>in</strong>ds. Whenapplication development was approached about the literalusage it was discovered that this QA system was runn<strong>in</strong>ga 'known bad' <strong>in</strong>ternal build of the application <strong>and</strong>upgrad<strong>in</strong>g to the correct build removed the issue.8. ConclusionIn this paper we described how <strong>Oracle</strong> 10g offers acomprehensive tun<strong>in</strong>g solution by provid<strong>in</strong>g automaticperformance diagnosis <strong>and</strong> tun<strong>in</strong>g via ADDM. Thisaddresses the ever-<strong>in</strong>creas<strong>in</strong>g performance tun<strong>in</strong>gchallenges currently faced by database adm<strong>in</strong>istrators.We def<strong>in</strong>ed a new measure called Database Time thatallows for comparison of the performance impact ofvarious database components with each other. We alsodescribed what types of performance measurements areneeded for accurate performance diagnosis, as well ashow we obta<strong>in</strong> them <strong>in</strong> a manner that has marg<strong>in</strong>al impacton the system. This solution also obviates the need toreproduce a problem <strong>in</strong> order to diagnose it.ADDM <strong>in</strong>corporates a holistic view of the system, <strong>and</strong>by us<strong>in</strong>g database time <strong>in</strong> conjunction with the twodimensionalDBTime-graph it is able to quickly isolatethe root causes of performance bottlenecks affect<strong>in</strong>g thethroughput of the system. ADDM provides specificactionable recommendations with an estimate of thebenefit for alleviat<strong>in</strong>g performance problems.


The results of runn<strong>in</strong>g ADDM on a variety ofworkloads <strong>and</strong> production systems with<strong>in</strong> <strong>Oracle</strong>demonstrates the benefits <strong>and</strong> practicality of our approachfor throughput tun<strong>in</strong>g.AcknowledgementsThe authors would like to thank all the members of theServer Manageability team at <strong>Oracle</strong> for their valuablefeedback <strong>in</strong> all stages of this project. We would like tothank Connie Green for provid<strong>in</strong>g helpful comments onan earlier version of this paper.References[BE03] D. G. Benoit. <strong>Automatic</strong> <strong>Diagnosis</strong> of <strong>Performance</strong>Problems <strong>in</strong> Database Management Systems, PhD Thesis,Queen’s University, Canada, 2003.[BR94] K. P. Brown, M. Mehta, M.J. Carey, M. Livny: TowardsAutomated <strong>Performance</strong> <strong>Tun<strong>in</strong>g</strong> for Complex Workloads. 20thInternational Conference on Very Large Data Bases, Santiago,Chile, 1994.[CH97] S. Chaudhuri, V. Narasayya: An Efficient, Cost-drivenIndex <strong>Tun<strong>in</strong>g</strong> Wizard for Microsoft SQL Server, 23rdInternational Conference on Very Large Data Bases, Athens,Greece, 1997.[CH00] S. Chaudhuri <strong>and</strong> G. Weikum: Reth<strong>in</strong>k<strong>in</strong>g DatabaseSystem Architecture: Towards a Self-tun<strong>in</strong>g RISC-styleDatabase System. 26th International Conference on Very LargeData Bases, Cairo, Egypt, 2000.[DA02] B. Dageville, M. Zait: SQL Memory Management <strong>in</strong><strong>Oracle</strong>9i, 28th International Conference on Very Large DataBases, Hong Kong, Ch<strong>in</strong>a, 2002.[EL03] S. Elnaffar, W. Powley, D. Benoit, P. Mart<strong>in</strong>: Today’sDBMSs: How Autonomic Are They? Proceed<strong>in</strong>gs of the FirstIEEE International Autonomic Systems Workshop, Prague,DEXA 2003.[GA96] Gartner Group: Total Cost of Ownership: The Impact ofSystem Management Tools, 1996.[HE97] J. L. Hellerste<strong>in</strong>. Automated <strong>Tun<strong>in</strong>g</strong> Systems: BeyondDecision Support. In the proceed<strong>in</strong>gs on ComputerMeasurement Group, 1997[HU02] Hurwitz Group: Achiev<strong>in</strong>g Faster Time-to-Benefit <strong>and</strong>Reduced TCO with <strong>Oracle</strong> Certified Configurations, March2002.[IBG8] IBM Corporation: DB2 Universal Database Version 8Guide to GUI Tools for Adm<strong>in</strong>istration <strong>and</strong> Development, IBMCorporation, 2003.[MSPD] Microsoft Corporation: RDBMS <strong>Performance</strong> <strong>Tun<strong>in</strong>g</strong>Guide for Data Warehous<strong>in</strong>g, Chapter 20, SQL Server 2000Resource Kit.[ORM9] <strong>Oracle</strong> Corporation: <strong>Oracle</strong> 9i Database Manageability,<strong>Oracle</strong> White Paper,http://www.oracle.com/technology/products/manageability/database/pdf/<strong>Oracle</strong>9iManageabilityBWP.pdf[ORM10] <strong>Oracle</strong> Corporation: <strong>Oracle</strong> Database 10g: The Self-Manag<strong>in</strong>g Database, <strong>Oracle</strong> White Paper,http://www.oracle.com/technology/products/manageability/database/pdf/twp03/TWP_manage_self_manag<strong>in</strong>g_database.pdf[ORP8] <strong>Oracle</strong> Corporation: <strong>Oracle</strong> 8i Design<strong>in</strong>g <strong>and</strong> <strong>Tun<strong>in</strong>g</strong> for<strong>Performance</strong> Release 2, <strong>Oracle</strong> 8i Documentation,http://tahiti.oracle.com[ORP9] <strong>Oracle</strong> Corporation: <strong>Oracle</strong> 9i Database <strong>Performance</strong><strong>Tun<strong>in</strong>g</strong> Guide <strong>and</strong> Reference, <strong>Oracle</strong> 9i Documentation,http://tahiti.oracle.com[ORQ9] <strong>Oracle</strong> Corporation: Query Optimization <strong>in</strong> <strong>Oracle</strong> 9i,<strong>Oracle</strong> White Paper,http://www.oracle.com/technology/products/bi/pdf/o9i_optimization_twp.pdf[ORQ10] <strong>Oracle</strong> Corporation: The Self-Manag<strong>in</strong>g Database:Guided Application <strong>and</strong> SQL <strong>Tun<strong>in</strong>g</strong>, <strong>Oracle</strong> White Paper,http://www.oracle.com/technology/products/manageability/database/pdf/twp03/TWP_manage_automatic_SQL_tun<strong>in</strong>g.pdf[ORS10] <strong>Oracle</strong> Corporation: The Self-Manag<strong>in</strong>g Database:Proactive Space <strong>and</strong> Schema Object Management, <strong>Oracle</strong>Presentation,http://www.oracle.com/technology/products/manageability/database/pdf/ow03p/40170p.pdf[ORSP] <strong>Oracle</strong> Corporation: Diagnos<strong>in</strong>g <strong>Performance</strong>Bottlenecks us<strong>in</strong>g Statspack <strong>and</strong> The <strong>Oracle</strong> <strong>Performance</strong>Method, <strong>Oracle</strong> White Paper,http://www.oracle.com/technology/deploy/performance/pdf/statspack_opm4.pdf[ORSP2] <strong>Oracle</strong> Corporation: Diagnos<strong>in</strong>g <strong>Performance</strong> Us<strong>in</strong>gStatspack, <strong>Oracle</strong> White Paper,http://www.oracle.com/technology/deploy/performance/pdf/statspack.pdf[WE94] G. Weikum, C. Hasse, A. Mönkeberg, P. Zabback: TheCOMFORT <strong>Automatic</strong> <strong>Tun<strong>in</strong>g</strong> Project, Information Systems,Vol. 19, No. 5, pp. 381-432, 1994.[WE02] G. Weikum, A. Mönkeberg, C. Hasse, P. Zabback:Selftun<strong>in</strong>g Database Technology <strong>and</strong> Information Services:From Wishful Th<strong>in</strong>k<strong>in</strong>g to Viable Eng<strong>in</strong>eer<strong>in</strong>g, 28thInternational Conference on Very Large Data Bases, HongKong, Ch<strong>in</strong>a, 2002.[IBP8] IBM Corporation: DB2 Universal Database Version 8Adm<strong>in</strong>istration Guide: <strong>Performance</strong>, IBM Corporation, 2003.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!