Oracle Database 12c features for DBA

22
Oracle Database 12c features for DBA By: Karan Kukreja

Transcript of Oracle Database 12c features for DBA

Page 1: Oracle Database 12c features for DBA

Oracle Database 12c features for DBA

By:Karan Kukreja

Page 2: Oracle Database 12c features for DBA

Points to note before the presentation

• This slide is self made• I don’t know everything

Page 3: Oracle Database 12c features for DBA

Features• Adaptive execution plans during runtime• PGA_AGGREGATE_LIMIT• Enhanced Statistics options• Renaming a datafile online• Fetch First X Rows only• Table restoration using rman• Invisible columns• Sql statements in rman directly • preupgrd.sql and parallel upgrade utility• Real-time ADDM analysis

Page 4: Oracle Database 12c features for DBA

Adaptive execution plans during runtime

• Execution of a statement can start with one plan, and (during execution) switch to another.

• Correct it in flight.• It is enabled during the hard parse, and used

during execution.• As the statement executes, if the embedded

counters for actual cardinality cross those limits, it will switch plan.

Page 5: Oracle Database 12c features for DBA

• Estimated outcome

Page 6: Oracle Database 12c features for DBA

• Actual number of rows

Page 7: Oracle Database 12c features for DBA

• Look what it did ?

Page 8: Oracle Database 12c features for DBA

PGA_AGGREGATE_LIMIT

• So far we have been using PGA_AGGREGATE_TARGET which is like a soft limit.

• PGA memory consumption can go beyond PGA_AGGREGATE_TARGET at times.

• PGA_AGGREGATE_LIMIT is a hard limit. If this limit is reached, Oracle will terminate sessions consuming the most untunable PGA.

Page 9: Oracle Database 12c features for DBA

• Jobs that are killed end with a notification : ORA-04036: PGA memory used by the instance exceeds PGA_AGGREGATE_LIMIT

• Default value is calculated as below :• 1. 2 GB

2. Two times of PGA_AGGREGATE_TARGET parameter • 3. The value of PROCESS parameter * 3M

• In oracle apps , this is set to 0 , which means the default value, which could be any fro above 3.

Page 10: Oracle Database 12c features for DBA

• How to find which process caused ORA-04036 ?• Use below steps : • dba_hist_active_sess_history and sort by PGA

usage in Desc order. • The top in the list is the sql_id which has issues. • Use query in reference URL to find the rows

returned / plan changed when it got bad.

Page 11: Oracle Database 12c features for DBA

Enhanced Statistics options• DBMS_STATS.GATHER_SYSTEM_STATS has now an option to gather system stats for

an Exadata machine. ( It actually came in 11.2.0.4 onwards).• Allows concurrent statistics collection using job scheduler, AQ and resource manager.

Can reduce time to gather stats overall however the system should have the capacity to take the load.

• Has to be explicitly enabled.• Cardinality feedback is now renamed to Statistic feedback. *• Dynamic Sampling has now been renamed to Dynamics Statistics.*• 2 new types of histograms are introduced , top frequency and hybrid. ( other being

frequency and height based). • Online stats gathering during CTAS and IAS and during partition creation. ( has some

restrictions though).• It is possible to have session-private statistics for global temporary tables.

• * will be covered later

Page 12: Oracle Database 12c features for DBA

Renaming a datafile online

• Release 12c made is more easy , all steps taken care by just giving the below command :

• ALTER DATABASE MOVE DATAFILE '/u01/app/oracle/oradata/cdb1/system01.dbf' TO '/tmp/system01.dbf';

Page 13: Oracle Database 12c features for DBA

Fetch First X Rows only

• Prior to 12 c , to get the top 5 the query would be :SELECT ename, sal FROM ( SELECT ename, sal, RANK() OVER (ORDER BY sal DESC) sal_rank FROM emp ) WHERE sal_rank <= 10;

• IN 12c , that’s taken care using FETCH FIRST N ROWS ONLY as below :

SELECT val FROM rownum_order_test ORDER BY val DESC FETCH FIRST 5 ROWS ONLY;

• 12c also supports queries for pagination , fetching last 20% etc. ( refer to references for more details).

Page 14: Oracle Database 12c features for DBA

Table restoration using rman

• Table Point In Time Recovery (PITR)

• Table Point In Time Recovery (PITR) to Dump File

• Table Point In Time Recovery (PITR) in a Pluggable Database (PDB)

Page 15: Oracle Database 12c features for DBA

• General syntax :

• RECOVER TABLE 'TEST'.'T1' UNTIL SCN 1853267 AUXILIARY DESTINATION '/u01/aux' REMAP TABLE 'TEST'.'T1':'T1_PREV';

• Auxiliary is where it will generate an auxiliary database only with the file it has to extract.

Page 16: Oracle Database 12c features for DBA

Sql statements in rman directly

Page 17: Oracle Database 12c features for DBA

preupgrd.sql and parallel upgrade utility

• Earlier used was utlu121s.sql however that has been changed to preupgrd.sql

• Apart from verification , it gives a list of changes to be done as part of fixup scripts.

In Earlier releases there was no option to do an upgrade in parallel. catupgrd.sql is now replaced with catctl.pl utility. Syntax : cd $ORACLE_12_HOME/perl/bin $ ./perl catctl.pl –n 3 -catupgrd.sql

Page 18: Oracle Database 12c features for DBA

Real-time ADDM analysis

• Needs OEM 12 c • Helpful during hung/unresponsive DB time• Steps :

• Select the Emergency Monitoring option from the Performance menu on the Access the Database Home page.

• This will show the top blocking sessions in the Hang Analysis table.• Select the Real-Time ADDM option from the Performance to

perform Real-time ADDM analysis.• After collecting the performance data, click on the Findings tab to

get the interactive summary of all the findings.

Page 19: Oracle Database 12c features for DBA

• What is dynamic Sampling ?• Oracle Database 10g introduced Dynamic

Sampling to allow the optimizer to gather additional information at parse time if database statistics were missing, stale or insufficient to produce a good execution plan.

• Value from 1 to 10 , default value is 2.

Page 20: Oracle Database 12c features for DBA

• So what is cardinality feedback ?• When the optimizer generates an execution plan the presence of

missing statistics, stale statistics, complex predicates or complex operators may trigger the optimizer to monitor the cardinality of operations in the plan. Once the execution is complete, if there is a significant difference between the estimated and actual cardinalities, the actual cardinalities are stored in the SGA for later use and the statement is marked as reoptimizable. On next execution the statement is reoptimized using the stored cardinalities, allowing a better plan to be determined. Cardinality feedback is statement specific and is lost if the instance is restarted or the statement is aged out of the shared pool. In Oracle Database 12c, cardinality feedback has been renamed to statistics feedback.

Page 21: Oracle Database 12c features for DBA

Questions ?