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

The best Oracle Database 12c Tuning Features for Developers

Jan 09, 2017

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: The best Oracle Database 12c Tuning Features for Developers

Oracle Database 12c

The Best Oracle Database 12c Tuning Features for Developers

and DBAs

Presentedby: AlexZaballa,OracleDBA

Page 2: The best Oracle Database 12c Tuning Features for Developers

Alex Zaballa

http://alexzaballa.blogspot.com/

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

Page 3: The best Oracle Database 12c Tuning Features for Developers

Workedfor7 yearsinBrazil asanOracleDeveloper.2000- 2007

Workedfor8 yearsinAngolaasanOracleDBAfortheMinistryofFinance.2007- 2015

Page 4: The best Oracle Database 12c Tuning Features for Developers
Page 5: The best Oracle Database 12c Tuning Features for Developers

Oracle Database 12c

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

Page 6: The best Oracle Database 12c Tuning Features for Developers

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: The best Oracle Database 12c Tuning Features for Developers

Articlesabout12c

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

Page 8: The best Oracle Database 12c Tuning Features for Developers

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

Page 9: The best Oracle Database 12c Tuning Features for Developers

OracleAnnouncesBetaAvailabilityofOracleDatabase12cRelease2 - Oct26,2015

• PLUGGABLEDATABASESFrom252to4096

• HOTCLONINGDon’tneedtoputthesourceinread-onlyforcloning

• SHARDINGIt’slikepartitioninginasharednothingdatabaseThedataissplitintomultipledatabases

• In-MemoryIn-MemorycolumnStoreonActiveDataGuardHeatMap

• APPLICATIONCONTAINERPluggableDatabaseswillshareapplicationobjects

• Moreisolation,resourcemanagerwilllimitthememoryinadditiontoCPUandI/O.• AWRwillworkonActiveDataGuardDatabase:youcantuneyourreportingdatabase

Page 10: The best Oracle Database 12c Tuning Features for Developers

AvailabilityofOracleDatabase12.2

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

Page 11: The best Oracle Database 12c Tuning Features for Developers

OracleDatabaseReleaseStatusMOSNote:742060.1

Page 12: The best Oracle Database 12c Tuning Features for Developers

Multitenant

Source:OracleDocumentation

Page 13: The best Oracle Database 12c Tuning Features for Developers

Multitenant

Is it a Tuning Feature?

Page 14: The best Oracle Database 12c Tuning Features for Developers

Source:OracleDocumentation

Page 15: The best Oracle Database 12c Tuning Features for Developers

Multitenant

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

Page 16: The best Oracle Database 12c Tuning Features for Developers

Multitenant

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

Page 17: The best Oracle Database 12c Tuning Features for Developers

Multitenant

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

Page 18: The best Oracle Database 12c Tuning Features for Developers

In-Memory

Source:OracleDocumentation

Page 19: The best Oracle Database 12c Tuning Features for Developers

In-MemorySIMDVectorProcessing

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

Page 20: The best Oracle Database 12c Tuning Features for Developers

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: The best Oracle Database 12c Tuning Features for Developers

In-Memory

In-MemoryArea– astaticpoolinSGA

Page 22: The best Oracle Database 12c Tuning Features for Developers

In-Memory

Source:OracleBase.com

Page 23: The best Oracle Database 12c Tuning Features for Developers

In-MemoryAltertablehr.EMPLOYEES inmemory;

ALTERTABLEsalesMODIFYPARTITIONSALES_Q1_1998INMEMORY;

ALTERTABLEsalesINMEMORYNOINMEMORY(prod_id);

CREATETABLESPACEtbs_testDATAFILE'+DG01SIZE100MDEFAULTINMEMORY;

Page 24: The best Oracle Database 12c Tuning Features for Developers

In-Memory

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

Page 25: The best Oracle Database 12c Tuning Features for Developers

SQLQueryRowLimitsandOffsets

Page 26: The best Oracle Database 12c Tuning Features for Developers

SQLQueryRowLimitsandOffsets

Page 27: The best Oracle Database 12c Tuning Features for Developers

SQLQueryRowLimitsandOffsets

Top-NQueries– Pré 12c

Page 28: The best Oracle Database 12c Tuning Features for Developers

SQLQueryRowLimitsandOffsets

Page 29: The best Oracle Database 12c Tuning Features for Developers

SQLQueryRowLimitsandOffsets

Page 30: The best Oracle Database 12c Tuning Features for Developers

SQLQueryRowLimitsandOffsets

Page 31: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 32: The best Oracle Database 12c Tuning Features for Developers

ApproximateCountDistinct

ThisfunctionprovidesanalternativetotheCOUNT(DISTINCTexpr),withnegligibledeviationfromtheexactresult.

Page 33: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 34: The best Oracle Database 12c Tuning Features for Developers

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: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 36: The best Oracle Database 12c Tuning Features for Developers

SessionLevelSequences

Sessionlevelsequences areusedtoproduceuniquevaluesinasession.Oncethesessionends,thesequenceisreset.

GeneratingPrimaryKeysforaGlobalTemporaryTablewouldbeafieldwherethosekindsofsequencescouldbeused.

Page 37: The best Oracle Database 12c Tuning Features for Developers

SessionLevelSequences

CREATESEQUENCEsequence_testSTARTWITH1INCREMENTBY1SESSION/

Page 38: The best Oracle Database 12c Tuning Features for Developers

SessionLevelSequences

ALTERSEQUENCEsequence_testSESSION;

ALTERSEQUENCEsequence_testGLOBAL;

Page 39: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 40: The best Oracle Database 12c Tuning Features for Developers

SessionprivatestatisticsforGlobalTemporaryTables

Pre12c,statisticsgatheredforglobaltemporarytables(GTTs)werecommontoallsessions.

Page 41: The best Oracle Database 12c Tuning Features for Developers

SessionprivatestatisticsforGlobalTemporaryTables

On12c,bydefaultsession-privatestatisticsareenabled

SELECTDBMS_STATS.get_prefs('GLOBAL_TEMP_TABLE_STATS')FROMdual;

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

Page 42: The best Oracle Database 12c Tuning Features for Developers

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: The best Oracle Database 12c Tuning Features for Developers

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: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 45: The best Oracle Database 12c Tuning Features for Developers

TemporaryUndo

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

DMLsinaGlobalTemporaryTablesdonotgenerateREDO,butgenerateUNDO andthiswillresultinREDOgenerating.

Page 46: The best Oracle Database 12c Tuning Features for Developers

TemporaryUndo

altersessionsettemp_undo_enabled=true;

altersystemsettemp_undo_enabled=true;

**youcanchangeforthesessionorforthedatabase.*defaulttrue

Page 47: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 48: The best Oracle Database 12c Tuning Features for Developers

MultipleIndexesonthesamesetofColumns

Pre12c:

ORA-01408:suchcolumnlistalreadyindexederror.

Page 49: The best Oracle Database 12c Tuning Features for Developers

MultipleIndexesonthesamesetofColumns

Istheabilitytocreatemorethanoneindexonthesamesetofcolumnsin12c.

**Onlyoneoftheseindexescanbevisibleatatime

Page 50: The best Oracle Database 12c Tuning Features for Developers

MultipleIndexesonthesamesetofColumns

Whywouldyouwanttodothat?

• Uniqueversusnonunique

• B-treeversusbitmap

• Differentpartitioningstrategies

Page 51: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 52: The best Oracle Database 12c Tuning Features for Developers

LimitthePGA

SQL>showparameterpga

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

pga_aggregate_target ****

Page 53: The best Oracle Database 12c Tuning Features for Developers

LimitthePGA

PGA_AGGREGATE_LIMIT issettothegreaterof:

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

Page 54: The best Oracle Database 12c Tuning Features for Developers

StatisticsDuringLoads

Theabilitytogatherstatisticsautomaticallyduringbulkloads:

- CREATETABLEASSELECT

- INSERTINTO...SELECTintoanemptytableusingadirectpathinsert

Page 55: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 56: The best Oracle Database 12c Tuning Features for Developers

PartialIndexesforPartitionedTable

• Youcancreatelocalandglobalindexesonasubset ofthepartitionsofatable,enablingmoreflexibilityinindexcreation.

• Thisfeatureisnotsupportedforuniqueindexes,orforindexesusedforenforcinguniqueconstraints.

Page 57: The best Oracle Database 12c Tuning Features for Developers

PartialIndexesforPartitionedTable

Page 58: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 59: The best Oracle Database 12c Tuning Features for Developers

FullDatabaseCaching

Canbeusedtocachetheentiredatabaseinmemory.Itshouldbeusedwhenthebuffercachesizeofthedatabaseinstanceisgreaterthanthewholedatabasesize.

Page 60: The best Oracle Database 12c Tuning Features for Developers

AdaptiveQueryOptimization

ê

AdaptivePlans

ê

AdaptiveJoinMethod

Page 61: The best Oracle Database 12c Tuning Features for Developers

AdaptiveJoinMethod

OptimizercanchangejoinfromNestedLooptoHashJoinandviceversa.

Why?Optimizermistakes§ EstimatedRowsandActualrowsaredifferent

Before12crequiresDBA/Developerintervention

Page 62: The best Oracle Database 12c Tuning Features for Developers

AdaptiveJoinMethod

Source:OracleDocumentation

Page 63: The best Oracle Database 12c Tuning Features for Developers

AdaptiveJoinMethod

ParametersthatcontrolAdaptivePlans:

Name Type Valueoptimizer_adaptive_features boolean TRUE

optimizer_adaptive_reporting_only boolean FALSEoptimizer_features_enable string 12.1.0.1

Page 64: The best Oracle Database 12c Tuning Features for Developers

ExplainPlancommandshowsthedefaultplan

Source:OracleDocumentation

Page 65: The best Oracle Database 12c Tuning Features for Developers

DBMS_XPLAN.DISPLAY_CURSORshowsthefinalplan

Source:OracleDocumentation

Page 66: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 67: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

• Sql MonitoringrequiresbothDiagnosticsandTuningPacklicenses

Page 68: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

• MONITORHintSELECT/*+MONITOR*/

• Allparallelstatements

• After5secondsofCPU/IOtimespentforserialqueries

Page 69: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 70: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 71: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 72: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 73: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 74: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 75: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 76: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoringSPOOL/tmp/report_sql_monitor.htm

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

SPOOLOFF

Page 77: The best Oracle Database 12c Tuning Features for Developers

Real-TimeSQLMonitoring

Page 78: The best Oracle Database 12c Tuning Features for Developers

DEMO

Page 79: The best Oracle Database 12c Tuning Features for Developers

SQLcl

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

Page 80: The best Oracle Database 12c Tuning Features for Developers
Page 81: The best Oracle Database 12c Tuning Features for Developers

ThankYou

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