Oracle英文版培训课件之Performance Tuning:les-08Tuning the Shared Pool_第1页
Oracle英文版培训课件之Performance Tuning:les-08Tuning the Shared Pool_第2页
Oracle英文版培训课件之Performance Tuning:les-08Tuning the Shared Pool_第3页
Oracle英文版培训课件之Performance Tuning:les-08Tuning the Shared Pool_第4页
Oracle英文版培训课件之Performance Tuning:les-08Tuning the Shared Pool_第5页
已阅读5页,还剩35页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

TuningtheSharedPoolObjectivesAftercompletingthislesson,youshouldbeabletodothefollowing:DiagnosesharedpoolproblemsSizethesharedpoolSizethereservedareaKeepobjectsinthesharedpoolSharedPoolArchitectureMajorcomponentsofthesharedpoolare:LibrarycacheDatadictionarycacheUserglobalarea(UGA)forsharedserversessionsDatabasebuffercacheRedologbuffer

SharedpoolLibrarycacheDatadictionarycache

SharedareasLargepool

UGASharedPoolOperationThesharedpoolismanagedbyanLRUalgorithm.Newobjectsrequirememoryallocations.Re-creatableobjectsareagedoutofthecache.Objectsaremadeupofchunksofmemory.Amemoryallocationisawholechunk.Achunkiscontiguous.TheLibraryCacheStorescomplexobjectmetadataassociatedwithcursorsStoresSQLstatementsandPL/SQLblocksthataretobesharedbyusersPreventsstatementreparsingSQLAREASQLandPL/SQLStorageCursorcontextareafor

SELECTstatement2Cursorcontextareafor

SELECTstatement1SharedpoolSELECTstatement2SELECTstatement1SELECTstatement1CursorUsageandParsingParseprocedure:1. Findandexecuteanopencursor.2. Findaclosedcursorinthesessioncache.3. Searchthehashchains(softparse).4. Constructthecursor(hardparse).OpencursorsClosedcursorsSessionmemory(UGA)Sharedpool(SGA)CursorhandlesHashchains1234ImportantSharedPoolLatcheslatch:sharedpoolprotectsmemoryallocationsinthesharedpool.latch:librarycachelocatesmatchingSQLinthesharedpool.MutexAmutualexclusionobjectallows:SharingofaresourcewithoutcorruptionSharedaccessforreadsExclusiveaccessforupdateEachobjecttohaveitsownmutexBenefitsofMutexPerformanceisimprovedwithmutexes.Mutexes:AresmallerandfasterHavelesspotentialforcontentionReplacelatchesandpinsMutexViewsandStatisticsMutexviews:V$MUTEX_SLEEPV$MUTEX_SLEEP_HISTORYMutexwaitevents:cursor:mutexXcursor:mutexScursor:pinXcursor:pinScursor:pinSwaitonXMutex-ProtectedOperationsFromonward,mutexprotects:SelectsfromV$SQLSTATSearchesofchildcursorlistsStatspack/AWRIndicatorsStatspackandAWRreportsincludeindicators:LoadProfileInstanceEfficienciesTopWaitEventsTimeModelLoadProfileLoadProfilePerSecondPerTransaction~~~~~~~~~~~~------------------------------Usercalls:4.2921.78Parses:188.09954.20Hardparses:80.00405.85%BlockschangedperRead:0.18RecursiveCall%:99.78Rollbackpertransaction%:9.76RowsperSort:8.47InstanceEfficienciesInstanceEfficiencyPercentages~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~BufferNowait%:100.00RedoNoWait%:100.00BufferHit%:99.87In-memorySort%:100.00LibraryHit%:87.90SoftParse%:57.47ExecutetoParse%:22.50LatchHit%:100.00ParseCPUtoParseElapsd%:83.16%Non-ParseCPU:17.88SharedPoolStatisticsBeginEnd------------MemoryUsage%:92.7592.97%SQLwithexecutions>1:72.6272.28%MemoryforSQLw/exec>1:92.3592.17TopWaitsTop5TimedEventsAvg%Total~~~~~~~~~~~~~~~~~~waitCallEventWaitsTime(s)(ms)Time----------------------------------------------------CPUtime19098.0latch:librarycache76119.8latch:sharedpool49116.4dbfilesequentialread1,34300.2logfileparallelwrite5405.1-------------------------------------------------------TimeModelTimeModelSystemStats->Orderedby%ofDBtimedesc,Statisticname %ofStatisticTime(s)DBtime------------------------------------------------------sqlexecuteelapsedtime399.595.6DBCPU269.364.4parsetimeelapsed126.830.3hardparseelapsedtime111.926.8PL/SQLcompilationelapsedtime6.61.6PL/SQLexecutionelapsedtime5.91.4connectionmanagementcallelapsed4.91.2failedparseelapsedtime4.01.0hardparse(sharingcriteria)elaps2.3.5sequenceloadelapsedtime0.5.1hardparse(bindmismatch)elapsed0.2.0repeatedbindelapsedtime0.1.0DBtime417.9LibraryCacheActivityLibraryCacheActivityDB/Inst:ORCL/orclSnaps:61-71->"PctMisses"shouldbeverylowGetPctPinPctInvali-NamespaceRequestsMissRequestsMissReloadsdations-----------------------------------------------------------BODY3327.345014.0460CLUSTER490.02003.060INDEX5100.035,3000.000SQLAREA18,88096.989,90436.54960TerminologyGets:(Parse)Thenumberoflookupsforobjects

ofthenamespacePins:(Execution)ThenumberofreadsorexecutionsoftheobjectsofthenamespaceReloads:(Parse)Thenumberoflibrarycachemissesontheexecutionstep,therebycausinganimplicitreparsingoftheSQLstatementInvalidations:ThenumberoftimesanobjectismodifiedbyaDDL,causingalldependentobjectstobemarkedinvalidV$SGASTATV$SGAINFOV$LIBRARYCACHEV$LIBRARY_CACHE_MEMORYV$SHARED_POOL_RESERVEDV$SQLSTATSV$SQLV$SQLAREAV$SQLTEXTV$DB_OBJECT_CACHEDiagnosticTools

forTuningtheSharedPoolParametersaffectingthecomponents:SHARED_POOL_SIZE,OPEN_CURSORSSESSION_CACHED_CURSORS,CURSOR_SPACE_FOR_TIMECURSOR_SHARING,SHARED_POOL_RESERVED_SIZEsp_m_n.lstreport.txtDatadictionary

cacheSharedpoolLibrarycacheSharedSQLandPL/SQLViewsLibraryCacheReloadsReloadsshouldbelessthan1%ofthepins:Ifthereloads-to-pinsratioisgreaterthan1%,increasethevalueoftheSHARED_POOL_SIZEparameter.SQL>SELECTSUM(pins)"Executions", 2SUM(reloads)"CacheMisses",3SUM(reloads)/SUM(pins)4FROMV$LIBRARYCACHE;ExecutesPROC1—>1stpin,1loadExecutesPROC1

—>2ndpin,noreloadExecutesPROC1

—>3rdpin,noreloadExecutesPROC1

—>4thpin,noreloadFourpinsandnoreloadsInvalidationsThenumberoftimesobjectsofthenamespacewere

markedinvalid,causingreloads:SQL>SELECTCOUNT(*)FROMhr.employees;SQL>SELECTnamespace,pins,reloads,2invalidations3FROMV$LIBRARYCACHE;SQL>executeDBMS_STATS.GATHER_TABLE_STATS->('HR','EMPLOYEES');SQL>SELECTCOUNT(*)FROMhr.employees;SQL>SELECTnamespace,pins,reloads,2invalidations3FROMV$LIBRARYCACHE;AvoidHardParsesInanOLTPsystem,reducemissesbykeepinghardparsingtoaminimum:Makesurethatuserscansharestatements.Preventfrequentlyusedstatementsfrombeingagedoutbyallocatingenoughspace.Avoidinvalidationsthatinducereparsing.AreCursorsBeingShared?CheckGETHITRATIOinV$LIBRARYCACHE:Determinewhichstatementscouldbeshared:SQL>SELECTplan_hash_value,count(*)2FROMV$SQL3GROUPBYplan_hash_valueORDERBY2DESCSQL>SELECTsql_text,executions2FROMV$SQLAREA3WHEREplan_hash_value=NNNNNNNNNSQL>SELECTgethitratio2FROMV$LIBRARYCACHE3WHEREnamespace='SQLAREA';SharingCursorsValuesforCURSOR_SHARINGare:EXACTSIMILARFORCEAvoidingSoftParsesReducingsoftparsesreduceslibrarycachelatchcontention.Keepsoftparsingtoaminimumby:SettingSESSION_CACHED_CURSORSSettingHOLD_CURSORintheapplicationprecompilerSettingCURSOR_SPACE_FOR_TIMEAvoidingFragmentationAvoidfragmentationby:Upgradingto10.2.0.xKeepingfrequentlyrequiredlargeobjectsReservingspaceforlargeobjectsEliminatinglargeanonymousPL/SQLblocksEnablingtheuseoflargepoolSizingtheSharedPoolUseAutomaticSharedMemoryManagement.UsetheSharedPoolAdvisorandconfirmusingotherdiagnosticswhendatahasoperationalhistory.Use40percentoftheSGAsizetostart,whenthereisnohistory.Monitorandadjustasneeded.Donotincreasethesizewhenfreememoryisavailable.SQL>SELECT*FROMV$SGASTAT2WHERENAME='freememory'3ANDPOOL='sharedpool';SharedPoolAdvisorySQL>SELECTshared_pool_size_for_estimateAS2pool_size,estd_lc_size,3estd_lc_time_saved4FROMV$SHARED_POOL_ADVICE;POOL_SIZEESTD_LC_SIZEESTD_LC_TIME_SAVED----------------------------------------328786840157868481778685617786864177868721778688017786888177868SharedPoolAdvisorLargeMemoryRequirementsSatisfyrequestsforlargecontiguousmemory.Reservecontiguousmemorywithinthe

sharedpool.SHARED_POOL_SIZESHARED_POOL_RESERVED_SIZEDatadictionary

cacheSharedpoolLibrarycacheSharedSQLandPL/SQLV$SHARED_POOL_RESERVEDReservedareaTuningtheSharedPool

ReservedSpaceIFREQUEST_FAILURESAction>0andincreasingANDRequest_misses>0IncreaseSHARED_POOL_

RESERVED_SIZE>0andincreasingANDFree_memory=>50%ofSHARED_POOL_RESERVED_SIZEIncreaseSHARED_POOL_

SIZE=0ORFree_memory=>50%ofSHARED_POOL_RESERVED_SIZEDecreaseSHARED_POOL_

RESERVED_SIZEKeepingLargeObjectsFindthosePL/SQLobjectsthatarenotkeptinthelibrarycache:Pinlargepackagesinthelibrarycache:SQL>EXECUTEDBMS_SHARED_POOL.KEEP(‘package_name’);

SQL>SELECT*FROMV$DB_OBJECT_CACHE2WHEREsharable_mem>100003AND(type='PACKAGE'ORtype='PACKAGEBODY'OR4type='FUNCTION'ORtype='PROCEDURE')5ANDkept='NO';DataDictionaryCacheThedatadictionarycacheholdsrowimagesofdatadictionaryrows.Datadictionarycache

DatadictionaryStatspack/AWRreportoutput:Iftherearetoomanycachemisses,increasetheSHARED_POOL_SIZEparameter.DictionaryCacheMisses

GetPctFinalCacheRequestsMissUsage-------------------------------------dc_histogram_data5,58726.8411dc_histogram_defs92,5013.7899dc_object_grants24055.026dc_object_ids959,2930.1289dc_objects19,3855.7314UGAandOracleSharedServerSharedpoolPGASharedpool

or

LargepoolStackspacePGAStackspaceUsersessiondataCursorstateUGA

V$STATNAME

V$SESSTAT

V$MYSTATOPEN_CURSORSSESSION_CACHED_CURSORSC

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论