the best oracle database 12c tuning features for developers

81
Oracle Database 12c The Best Oracle Database 12c Tuning Features for Developers and DBAs Presented by: Alex Zaballa, Oracle DBA

Upload: guatemala-user-group

Post on 09-Jan-2017

66 views

Category:

Technology


2 download

TRANSCRIPT

Oracle Database 12c

The Best Oracle Database 12c Tuning Features for Developers

and DBAs

Presentedby: AlexZaballa,OracleDBA

Alex Zaballa

http://alexzaballa.blogspot.com/

@alexzaballa206andcounting…https://www.linkedin.com/in/alexzaballa

Workedfor7 yearsinBrazil asanOracleDeveloper.2000- 2007

Workedfor8 yearsinAngolaasanOracleDBAfortheMinistryofFinance.2007- 2015

Oracle Database 12c

The Best Oracle Database 12c Tuning Features for Developers and DBAs

OracleOfficialDocumentation12.1.0.2

• http://docs.oracle.com/database/121/NEWFT/chapter12102.htm

OracleLearningLibrary(OLL)

• https://apexapps.oracle.com/pls/apex/f?p=44785:1:0

Articlesabout12c

• https://oracle-base.com/articles/12c/articles-12c

“Withmorethan500newfeatures,OracleDatabase12c isdesignedtogiveOraclecustomersexactlywhatthey’vetoldustheyneedforcloudcomputing,bigdata,security,andavailability.”

OracleAnnouncesBetaAvailabilityofOracleDatabase12cRelease2 - Oct26,2015

• PLUGGABLEDATABASESFrom252to4096

• HOTCLONINGDon’tneedtoputthesourceinread-onlyforcloning

• SHARDINGIt’slikepartitioninginasharednothingdatabaseThedataissplitintomultipledatabases

• In-MemoryIn-MemorycolumnStoreonActiveDataGuardHeatMap

• APPLICATIONCONTAINERPluggableDatabaseswillshareapplicationobjects

• Moreisolation,resourcemanagerwilllimitthememoryinadditiontoCPUandI/O.• AWRwillworkonActiveDataGuardDatabase:youcantuneyourreportingdatabase

AvailabilityofOracleDatabase12.2

Source:https://blogs.oracle.com/UPGRADE/entry/oracle_database_12_2_just

OracleDatabaseReleaseStatusMOSNote:742060.1

Multitenant

Source:OracleDocumentation

Multitenant

Is it a Tuning Feature?

Source:OracleDocumentation

Multitenant

Source:https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle

Multitenant

Source:https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle

Multitenant

Source:https://blogs.oracle.com/UPGRADE/entry/non_cdb_architecture_of_oracle

In-Memory

Source:OracleDocumentation

In-MemorySIMDVectorProcessing

Source:http://www.oracle.com/technetwork/database/in-memory/overview/twp-oracle-database-in-memory-2245633.html

In-Memory

Source:OracleDocumentation

Is it a Tuning Feature?

“Using Database In-Memory, businesses can instantaneouslyrun analytics and reports that previously took hours or days.”

In-Memory

In-MemoryArea– astaticpoolinSGA

In-Memory

Source:OracleBase.com

In-MemoryAltertablehr.EMPLOYEES inmemory;

ALTERTABLEsalesMODIFYPARTITIONSALES_Q1_1998INMEMORY;

ALTERTABLEsalesINMEMORYNOINMEMORY(prod_id);

CREATETABLESPACEtbs_testDATAFILE'+DG01SIZE100MDEFAULTINMEMORY;

In-Memory

Source:http://www.oracle.com/technetwork/database/in-memory/overview/twp-oracle-database-in-memory-2245633.html

SQLQueryRowLimitsandOffsets

SQLQueryRowLimitsandOffsets

SQLQueryRowLimitsandOffsets

Top-NQueries– Pré 12c

SQLQueryRowLimitsandOffsets

SQLQueryRowLimitsandOffsets

SQLQueryRowLimitsandOffsets

DEMO

ApproximateCountDistinct

ThisfunctionprovidesanalternativetotheCOUNT(DISTINCTexpr),withnegligibledeviationfromtheexactresult.

DEMO

PL/SQLFromSQLwith

functionIs_Number(xinvarchar2)returnvarchar2isPlsql_Num_Error exception;pragmaexception_init(Plsql_Num_Error,-06502);beginif(To_Number(x)isNOTnull)thenreturn'Y';elsereturn'';endif;exceptionwhenPlsql_Num_Error thenreturn'N';

endIs_Number;selectrownum,x,is_number(x)is_num fromt;

DEMO

SessionLevelSequences

Sessionlevelsequences areusedtoproduceuniquevaluesinasession.Oncethesessionends,thesequenceisreset.

GeneratingPrimaryKeysforaGlobalTemporaryTablewouldbeafieldwherethosekindsofsequencescouldbeused.

SessionLevelSequences

CREATESEQUENCEsequence_testSTARTWITH1INCREMENTBY1SESSION/

SessionLevelSequences

ALTERSEQUENCEsequence_testSESSION;

ALTERSEQUENCEsequence_testGLOBAL;

DEMO

SessionprivatestatisticsforGlobalTemporaryTables

Pre12c,statisticsgatheredforglobaltemporarytables(GTTs)werecommontoallsessions.

SessionprivatestatisticsforGlobalTemporaryTables

On12c,bydefaultsession-privatestatisticsareenabled

SELECTDBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS')FROMdual;

STATS------------------------------------------------------------------------------SESSION

SessionprivatestatisticsforGlobalTemporaryTables

Howtochange?

Behaviorpre12c:BEGINDBMS_STATS.set_global_prefs (pname =>'GLOBAL_TEMP_TABLE_STATS',pvalue =>'SHARED');

END;/

Backtodefaulton12c:BEGINDBMS_STATS.set_global_prefs (pname =>'GLOBAL_TEMP_TABLE_STATS',pvalue =>'SESSION');

END;/

SessionprivatestatisticsforGlobalTemporaryTables

Howtochangeforonetable?

BEGINdbms_stats.set_table_prefs('SCOTT','GTT_TEST','GLOBAL_TEMP_TABLE_STATS','SHARED');END;

BEGINdbms_stats.set_table_prefs('SCOTT','GTT_TEST','GLOBAL_TEMP_TABLE_STATS’,’SESSION');END;

DEMO

TemporaryUndo

GlobalTemporaryTables(GTT)holdthedatainatemporarytablespace.ThedatainGTTsareeitherdeletedaftercommitorkeptuntilthesessionisconnecteddependingofthedefinitionoftheGTT.(ONCOMMITPRESERVEORDELETEROWS).

DMLsinaGlobalTemporaryTablesdonotgenerateREDO,butgenerateUNDO andthiswillresultinREDOgenerating.

TemporaryUndo

altersessionsettemp_undo_enabled=true;

altersystemsettemp_undo_enabled=true;

**youcanchangeforthesessionorforthedatabase.*defaulttrue

DEMO

MultipleIndexesonthesamesetofColumns

Pre12c:

ORA-01408:suchcolumnlistalreadyindexederror.

MultipleIndexesonthesamesetofColumns

Istheabilitytocreatemorethanoneindexonthesamesetofcolumnsin12c.

**Onlyoneoftheseindexescanbevisibleatatime

MultipleIndexesonthesamesetofColumns

Whywouldyouwanttodothat?

• Uniqueversusnonunique

• B-treeversusbitmap

• Differentpartitioningstrategies

DEMO

LimitthePGA

SQL>showparameterpga

NAME TYPEVALUE-------------------------- ------------- ----------------------pga_aggregate_limit biginteger2G

pga_aggregate_target ****

LimitthePGA

PGA_AGGREGATE_LIMIT issettothegreaterof:

- 2GB(defaultvalue)- 200%ofPGA_AGGREGATE_TARGET- 3MBtimesthePROCESSESparameter

StatisticsDuringLoads

Theabilitytogatherstatisticsautomaticallyduringbulkloads:

- CREATETABLEASSELECT

- INSERTINTO...SELECTintoanemptytableusingadirectpathinsert

DEMO

PartialIndexesforPartitionedTable

• Youcancreatelocalandglobalindexesonasubset ofthepartitionsofatable,enablingmoreflexibilityinindexcreation.

• Thisfeatureisnotsupportedforuniqueindexes,orforindexesusedforenforcinguniqueconstraints.

PartialIndexesforPartitionedTable

DEMO

FullDatabaseCaching

Canbeusedtocachetheentiredatabaseinmemory.Itshouldbeusedwhenthebuffercachesizeofthedatabaseinstanceisgreaterthanthewholedatabasesize.

AdaptiveQueryOptimization

ê

AdaptivePlans

ê

AdaptiveJoinMethod

AdaptiveJoinMethod

OptimizercanchangejoinfromNestedLooptoHashJoinandviceversa.

Why?Optimizermistakes§ EstimatedRowsandActualrowsaredifferent

Before12crequiresDBA/Developerintervention

AdaptiveJoinMethod

Source:OracleDocumentation

AdaptiveJoinMethod

ParametersthatcontrolAdaptivePlans:

Name Type Valueoptimizer_adaptive_features boolean TRUE

optimizer_adaptive_reporting_only boolean FALSEoptimizer_features_enable string 12.1.0.1

ExplainPlancommandshowsthedefaultplan

Source:OracleDocumentation

DBMS_XPLAN.DISPLAY_CURSORshowsthefinalplan

Source:OracleDocumentation

DEMO

Real-TimeSQLMonitoring

• Sql MonitoringrequiresbothDiagnosticsandTuningPacklicenses

Real-TimeSQLMonitoring

• MONITORHintSELECT/*+MONITOR*/

• Allparallelstatements

• After5secondsofCPU/IOtimespentforserialqueries

Real-TimeSQLMonitoring

Real-TimeSQLMonitoring

Real-TimeSQLMonitoring

Real-TimeSQLMonitoring

Real-TimeSQLMonitoring

Real-TimeSQLMonitoring

Real-TimeSQLMonitoring

Real-TimeSQLMonitoringSPOOL/tmp/report_sql_monitor.htm

SELECTDBMS_SQLTUNE.report_sql_monitor(sql_id =>'5dhu4w0j59yp7',type=>'HTML',report_level =>'ALL')ASreportFROMdual;

SPOOLOFF

Real-TimeSQLMonitoring

DEMO

SQLcl

http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html

ThankYou

SlidesAvailable:http://www.slideshare.net/