otn tour 2016 - oracle database 12c - 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: alex-zaballa

Post on 16-Apr-2017

195 views

Category:

Technology


5 download

TRANSCRIPT

Page 1: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Oracle Database 12c

The Best Oracle Database 12c Tuning Features for Developers

and DBAs

Presentedby: AlexZaballa,OracleDBA

Page 2: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Alex Zaballa

http://alexzaballa.blogspot.com/

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

Page 3: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Workedfor7 yearsinBrazil asanOracleDeveloper.2000- 2007

Workedfor8 yearsinAngolaasanOracleDBAfortheMinistryofFinance.2007- 2015

Page 4: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs
Page 5: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Oracle Database 12c

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

Page 6: OTN TOUR 2016 - 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

Page 7: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Articlesabout12c

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

Page 8: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

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

Page 9: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

OracleAnnouncesBetaAvailabilityofOracleDatabase12cRelease2 - Oct26,2015

• PLUGGABLEDATABASESFrom252to4096

• HOTCLONINGDon’tneedtoputthesourceinread-onlyforcloning

• SHARDINGIt’slikepartitioninginasharednothingdatabaseThedataissplitintomultipledatabases

• In-MemoryIn-MemorycolumnStoreonActiveDataGuardHeatMap

• APPLICATIONCONTAINERPluggableDatabaseswillshareapplicationobjects

• Moreisolation,resourcemanagerwilllimitthememoryinadditiontoCPUandI/O.• AWRwillworkonActiveDataGuardDatabase:youcantuneyourreportingdatabase

Page 10: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

AvailabilityofOracleDatabase12.2

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

Page 11: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

OracleDatabaseReleaseStatusMOSNote:742060.1

Page 12: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Multitenant

Source:OracleDocumentation

Page 13: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Multitenant

Is it a Tuning Feature?

Page 14: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Source:OracleDocumentation

Page 15: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Multitenant

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

Page 16: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Multitenant

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

Page 17: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Multitenant

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

Page 18: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

In-Memory

Source:OracleDocumentation

Page 19: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

In-MemorySIMDVectorProcessing

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

Page 20: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

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.”

Page 21: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

In-Memory

In-MemoryArea– astaticpoolinSGA

Page 22: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

In-Memory

Source:OracleBase.com

Page 23: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

In-MemoryAltertablehr.EMPLOYEES inmemory;

ALTERTABLEsalesMODIFYPARTITIONSALES_Q1_1998INMEMORY;

ALTERTABLEsalesINMEMORYNOINMEMORY(prod_id);

CREATETABLESPACEtbs_testDATAFILE'+DG01SIZE100MDEFAULTINMEMORY;

Page 24: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

In-Memory

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

Page 25: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLQueryRowLimitsandOffsets

Page 26: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLQueryRowLimitsandOffsets

Page 27: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLQueryRowLimitsandOffsets

Top-NQueries– Pré 12c

Page 28: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLQueryRowLimitsandOffsets

Page 29: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLQueryRowLimitsandOffsets

Page 30: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLQueryRowLimitsandOffsets

Page 31: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 32: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

ApproximateCountDistinct

ThisfunctionprovidesanalternativetotheCOUNT(DISTINCTexpr),withnegligibledeviationfromtheexactresult.

Page 33: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 34: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

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;

Page 35: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 36: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SessionLevelSequences

Sessionlevelsequences areusedtoproduceuniquevaluesinasession.Oncethesessionends,thesequenceisreset.

GeneratingPrimaryKeysforaGlobalTemporaryTablewouldbeafieldwherethosekindsofsequencescouldbeused.

Page 37: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SessionLevelSequences

CREATESEQUENCEsequence_testSTARTWITH1INCREMENTBY1SESSION/

Page 38: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SessionLevelSequences

ALTERSEQUENCEsequence_testSESSION;

ALTERSEQUENCEsequence_testGLOBAL;

Page 39: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 40: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SessionprivatestatisticsforGlobalTemporaryTables

Pre12c,statisticsgatheredforglobaltemporarytables(GTTs)werecommontoallsessions.

Page 41: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SessionprivatestatisticsforGlobalTemporaryTables

On12c,bydefaultsession-privatestatisticsareenabled

SELECTDBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS')FROMdual;

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

Page 42: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

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;/

Page 43: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

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;

Page 44: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 45: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

TemporaryUndo

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

DMLsinaGlobalTemporaryTablesdonotgenerateREDO,butgenerateUNDO andthiswillresultinREDOgenerating.

Page 46: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

TemporaryUndo

altersessionsettemp_undo_enabled=true;

altersystemsettemp_undo_enabled=true;

**youcanchangeforthesessionorforthedatabase.*defaulttrue

Page 47: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 48: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

MultipleIndexesonthesamesetofColumns

Pre12c:

ORA-01408:suchcolumnlistalreadyindexederror.

Page 49: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

MultipleIndexesonthesamesetofColumns

Istheabilitytocreatemorethanoneindexonthesamesetofcolumnsin12c.

**Onlyoneoftheseindexescanbevisibleatatime

Page 50: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

MultipleIndexesonthesamesetofColumns

Whywouldyouwanttodothat?

• Uniqueversusnonunique

• B-treeversusbitmap

• Differentpartitioningstrategies

Page 51: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 52: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

LimitthePGA

SQL>showparameterpga

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

pga_aggregate_target ****

Page 53: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

LimitthePGA

PGA_AGGREGATE_LIMIT issettothegreaterof:

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

Page 54: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

StatisticsDuringLoads

Theabilitytogatherstatisticsautomaticallyduringbulkloads:

- CREATETABLEASSELECT

- INSERTINTO...SELECTintoanemptytableusingadirectpathinsert

Page 55: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 56: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

PartialIndexesforPartitionedTable

• Youcancreatelocalandglobalindexesonasubset ofthepartitionsofatable,enablingmoreflexibilityinindexcreation.

• Thisfeatureisnotsupportedforuniqueindexes,orforindexesusedforenforcinguniqueconstraints.

Page 57: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

PartialIndexesforPartitionedTable

Page 58: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 59: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

FullDatabaseCaching

Canbeusedtocachetheentiredatabaseinmemory.Itshouldbeusedwhenthebuffercachesizeofthedatabaseinstanceisgreaterthanthewholedatabasesize.

Page 60: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

AdaptiveQueryOptimization

ê

AdaptivePlans

ê

AdaptiveJoinMethod

Page 61: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

AdaptiveJoinMethod

OptimizercanchangejoinfromNestedLooptoHashJoinandviceversa.

Why?Optimizermistakes§ EstimatedRowsandActualrowsaredifferent

Before12crequiresDBA/Developerintervention

Page 62: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

AdaptiveJoinMethod

Source:OracleDocumentation

Page 63: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

AdaptiveJoinMethod

ParametersthatcontrolAdaptivePlans:

Name Type Valueoptimizer_adaptive_features boolean TRUE

optimizer_adaptive_reporting_only boolean FALSEoptimizer_features_enable string 12.1.0.1

Page 64: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

ExplainPlancommandshowsthedefaultplan

Source:OracleDocumentation

Page 65: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DBMS_XPLAN.DISPLAY_CURSORshowsthefinalplan

Source:OracleDocumentation

Page 66: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 67: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

• Sql MonitoringrequiresbothDiagnosticsandTuningPacklicenses

Page 68: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

• MONITORHintSELECT/*+MONITOR*/

• Allparallelstatements

• After5secondsofCPU/IOtimespentforserialqueries

Page 69: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 70: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 71: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 72: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 73: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 74: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 75: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 76: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoringSPOOL/tmp/report_sql_monitor.htm

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

SPOOLOFF

Page 77: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

Real-TimeSQLMonitoring

Page 78: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

DEMO

Page 79: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

SQLcl

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

Page 80: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs
Page 81: OTN TOUR 2016 - Oracle Database 12c - The Best Oracle Database 12c Tuning Features for Developers and DBAs

ThankYou

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