Skip navigation.

The Oracle Instructor

Syndicate content The Oracle Instructor
Explain, Exemplify, Empower
Updated: 15 hours 4 min ago

FREE webinar about Advanced #Oracle Database Administration

Tue, 2016-01-05 03:45

On behalf of Oracle University, I will be delivering a free webinar, Tuesday 26th January 2016:

http://www.oracle.com/uk/education/eblast/uk-dba-advanced-admin-181215-ol-2835011.html

Expect live demonstrations as the major content – I promise to keep the marketing part to a minimum :-)


Categories: DBA Blogs

Happy New Year 2016!

Thu, 2015-12-31 02:08

Another year has passed. I take the opportunity to thank you for visiting and to wish you a Happy New Year 2016!

Happy New Year 2016!

In case you didn’t recognize: That is supposed to look like fireworks, The Oracle Instructor style ;-)

2015 was a great year for uhesse.com with 345,000+ views and the crossing of the one million hits threshold. Top countries with more than 4,000 views in 2015 were

Visitors 2015

Visitors came from 202 countries, even China is on the list this year with 1,500+ views.

Hope to see all of you again here in 2016 :-)


Categories: DBA Blogs

Upgrade a Pluggable Database in #Oracle 12c

Tue, 2015-12-29 09:27

This is how an upgrade with pluggable databases looks conceptually:
You have two multitenant databases from different versions in place. Preferably they share the same storage, which allows to do the upgrade without having to move any datafiles
Initial state

You unplug the pluggable database from the first multitenant database, then you drop it. That is a fast logical operation that does not delete any files

unplug drop

Next step is to plug in the pluggable database into the multitenant database from the higher version

plug in

So far the operations were very fast (seconds). Next step takes longer, when you upgrade the pluggable database in its new destination

catupgrade.sql

Now let’s see that with details:

 

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
PL/SQL Release 12.1.0.1.0 - Production
CORE    12.1.0.1.0      Production
TNS for Linux: Version 12.1.0.1.0 - Production
NLSRTL Version 12.1.0.1.0 - Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oradata/CDB1/system01.dbf
/oradata/CDB1/pdbseed/system01.dbf
/oradata/CDB1/sysaux01.dbf
/oradata/CDB1/pdbseed/sysaux01.dbf
/oradata/CDB1/undotbs01.dbf
/oradata/CDB1/users01.dbf

6 rows selected.

SQL> host mkdir /oradata/PDB1

SQL> create pluggable database PDB1 admin user adm identified by oracle
  2  file_name_convert=('/oradata/CDB1/pdbseed/','/oradata/PDB1/');

Pluggable database created.

SQL> alter pluggable database all open;

Pluggable database altered.

SQL> alter session set container=PDB1;

Session altered.

SQL> create tablespace users datafile '/oradata/PDB1/users01.dbf' size 100m;

Tablespace created.

SQL> alter pluggable database default tablespace users;

Pluggable database altered.

SQL> grant dba to adam identified by adam;

Grant succeeded.

SQL> create table adam.t as select * from dual;

Table created.

The PDB should have its own subfolder underneath /oradata respectively in the DATA diskgroup IMHO. Makes not much sense to have the PDB subfolder underneath the CDBs subfolder because it may get plugged into other CDBs. Your PDB names should be unique across the enterprise anyway, also because of the PDB service that is named after the PDB.

I’m about to upgrade PDB1, so I run the pre upgrade script that comes with the new version

SQL> connect / as sysdba
Connected.

SQL> @/u01/app/oracle/product/12.1.0.2/rdbms/admin/preupgrd.sql

Loading Pre-Upgrade Package...


***************************************************************************
Executing Pre-Upgrade Checks in CDB$ROOT...
***************************************************************************


      ************************************************************

                 ====>> ERRORS FOUND for CDB$ROOT <<==== The following are *** ERROR LEVEL CONDITIONS *** 
that must be addressed prior to attempting your upgrade. Failure to do so will result in a failed upgrade. 
You MUST resolve the above errors prior to upgrade 
************************************************************ 
************************************************************ 
====>> PRE-UPGRADE RESULTS for CDB$ROOT <<==== ACTIONS REQUIRED: 
1. Review results of the pre-upgrade checks: /u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade.log 
2. Execute in the SOURCE environment BEFORE upgrade: /u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade_fixups.sql 
3. Execute in the NEW environment AFTER upgrade: /u01/app/oracle/cfgtoollogs/CDB1/preupgrade/postupgrade_fixups.sql 
************************************************************ 
*************************************************************************** 
Pre-Upgrade Checks in CDB$ROOT Completed. 
*************************************************************************** 
*************************************************************************** 
*************************************************************************** 
SQL> @/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/preupgrade_fixups
Pre-Upgrade Fixup Script Generated on 2015-12-29 07:02:21  Version: 12.1.0.2 Build: 010
Beginning Pre-Upgrade Fixups...
Executing in container CDB$ROOT

**********************************************************************
                      [Pre-Upgrade Recommendations]
**********************************************************************

                        *****************************************
                        ********* Dictionary Statistics *********
                        *****************************************

Please gather dictionary statistics 24 hours prior to
upgrading the database.
To gather dictionary statistics execute the following command
while connected as SYSDBA:
    EXECUTE dbms_stats.gather_dictionary_stats;

^^^ MANUAL ACTION SUGGESTED ^^^


           **************************************************
                ************* Fixup Summary ************

No fixup routines were executed.

           **************************************************
**************** Pre-Upgrade Fixup Script Complete *********************
SQL> EXECUTE dbms_stats.gather_dictionary_stats

Not much to fix in this case. I’m now ready to unplug and drop the PBD

SQL> alter pluggable database PDB1 close immediate;
SQL> alter pluggable database PDB1 unplug into '/home/oracle/PDB1.xml';
SQL> drop pluggable database PDB1;

PDB1.xml contains a brief description of the PDB and needs to be available for the destination CDB. Keep in mind that no files have been deleted

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
oracle@localhost:~$ . oraenv
ORACLE_SID = [CDB1] ? CDB2
The Oracle base remains unchanged with value /u01/app/oracle
oracle@localhost:~$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 29 07:11:16 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE    12.1.0.2.0      Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oradata/CDB2/system01.dbf
/oradata/CDB2/pdbseed/system01.dbf
/oradata/CDB2/sysaux01.dbf
/oradata/CDB2/pdbseed/sysaux01.dbf
/oradata/CDB2/undotbs01.dbf
/oradata/CDB2/users01.dbf

6 rows selected.

The destination CDB is on 12.1.0.2 and shares the storage with the source CDB running on 12.1.0.1. Actually, they are both running on the same server. Now I will check if there are any potential problems with the plug in

SQL> SET SERVEROUTPUT ON
DECLARE
compatible CONSTANT VARCHAR2(3) := CASE
DBMS_PDB.CHECK_PLUG_COMPATIBILITY(
pdb_descr_file => '/home/oracle/PDB1.xml',
pdb_name => 'PDB1')
WHEN TRUE THEN 'YES' ELSE 'NO'
END;
BEGIN
DBMS_OUTPUT.PUT_LINE(compatible);
END;
/SQL>   2    3    4    5    6    7    8    9   10   11
NO

PL/SQL procedure successfully completed.

SQL> select message, status from pdb_plug_in_violations where type like '%ERR%';

MESSAGE
--------------------------------------------------------------------------------
STATUS
---------
PDB's version does not match CDB's version: PDB's version 12.1.0.0.0. CDB's vers
ion 12.1.0.2.0.
PENDING

Now that was to be expected: The PDB is coming from a lower version. Will fix that after the plug in

SQL> create pluggable database PDB1 using '/home/oracle/PDB1.xml' nocopy;

Pluggable database created.

SQL> alter pluggable database PDB1 open upgrade;

Warning: PDB altered with errors.

SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

We saw the first three phases so far and everything was quite fast. Not so with the next step

oracle@localhost:~$ cd $ORACLE_HOME/rdbms/admin
oracle@localhost:/u01/app/oracle/product/12.1.0.2/rdbms/admin$ $ORACLE_HOME/perl/bin/perl catctl.pl -c 'PDB1' catupgrd.sql

Argument list for [catctl.pl]
SQL Process Count     n = 0
SQL PDB Process Count N = 0
Input Directory       d = 0
Phase Logging Table   t = 0
Log Dir               l = 0
Script                s = 0
Serial Run            S = 0
Upgrade Mode active   M = 0
Start Phase           p = 0
End Phase             P = 0
Log Id                i = 0
Run in                c = PDB1
Do not run in         C = 0
Echo OFF              e = 1
No Post Upgrade       x = 0
Reverse Order         r = 0
Open Mode Normal      o = 0
Debug catcon.pm       z = 0
Debug catctl.pl       Z = 0
Display Phases        y = 0
Child Process         I = 0

catctl.pl version: 12.1.0.2.0
Oracle Base           = /u01/app/oracle

Analyzing file catupgrd.sql
Log files in /u01/app/oracle/product/12.1.0.2/rdbms/admin
catcon: ALL catcon-related output will be written to catupgrd_catcon_17942.lst
catcon: See catupgrd*.log files for output generated by scripts
catcon: See catupgrd_*.lst files for spool files, if any
Number of Cpus        = 2
Parallel PDB Upgrades = 2
SQL PDB Process Count = 2
SQL Process Count     = 0
New SQL Process Count = 2

[CONTAINER NAMES]

CDB$ROOT
PDB$SEED
PDB1
PDB Inclusion:[PDB1] Exclusion:[]

Start processing of PDB1
[/u01/app/oracle/product/12.1.0.2/perl/bin/perl catctl.pl -c 'PDB1' -I -i pdb1 -n 2 catupgrd.sql]

Argument list for [catctl.pl]
SQL Process Count     n = 2
SQL PDB Process Count N = 0
Input Directory       d = 0
Phase Logging Table   t = 0
Log Dir               l = 0
Script                s = 0
Serial Run            S = 0
Upgrade Mode active   M = 0
Start Phase           p = 0
End Phase             P = 0
Log Id                i = pdb1
Run in                c = PDB1
Do not run in         C = 0
Echo OFF              e = 1
No Post Upgrade       x = 0
Reverse Order         r = 0
Open Mode Normal      o = 0
Debug catcon.pm       z = 0
Debug catctl.pl       Z = 0
Display Phases        y = 0
Child Process         I = 1

catctl.pl version: 12.1.0.2.0
Oracle Base           = /u01/app/oracle

Analyzing file catupgrd.sql
Log files in /u01/app/oracle/product/12.1.0.2/rdbms/admin
catcon: ALL catcon-related output will be written to catupgrdpdb1_catcon_18184.lst
catcon: See catupgrdpdb1*.log files for output generated by scripts
catcon: See catupgrdpdb1_*.lst files for spool files, if any
Number of Cpus        = 2
SQL PDB Process Count = 2
SQL Process Count     = 2

[CONTAINER NAMES]

CDB$ROOT
PDB$SEED
PDB1
PDB Inclusion:[PDB1] Exclusion:[]

------------------------------------------------------
Phases [0-73]         Start Time:[2015_12_29 07:19:01]
Container Lists Inclusion:[PDB1] Exclusion:[NONE]
------------------------------------------------------
Serial   Phase #: 0    PDB1 Files: 1     Time: 14s
Serial   Phase #: 1    PDB1 Files: 5     Time: 46s
Restart  Phase #: 2    PDB1 Files: 1     Time: 0s
Parallel Phase #: 3    PDB1 Files: 18    Time: 17s
Restart  Phase #: 4    PDB1 Files: 1     Time: 0s
Serial   Phase #: 5    PDB1 Files: 5     Time: 17s
Serial   Phase #: 6    PDB1 Files: 1     Time: 10s
Serial   Phase #: 7    PDB1 Files: 4     Time: 6s
Restart  Phase #: 8    PDB1 Files: 1     Time: 0s
Parallel Phase #: 9    PDB1 Files: 62    Time: 68s
Restart  Phase #:10    PDB1 Files: 1     Time: 0s
Serial   Phase #:11    PDB1 Files: 1     Time: 13s
Restart  Phase #:12    PDB1 Files: 1     Time: 0s
Parallel Phase #:13    PDB1 Files: 91    Time: 6s
Restart  Phase #:14    PDB1 Files: 1     Time: 0s
Parallel Phase #:15    PDB1 Files: 111   Time: 13s
Restart  Phase #:16    PDB1 Files: 1     Time: 0s
Serial   Phase #:17    PDB1 Files: 3     Time: 1s
Restart  Phase #:18    PDB1 Files: 1     Time: 0s
Parallel Phase #:19    PDB1 Files: 32    Time: 26s
Restart  Phase #:20    PDB1 Files: 1     Time: 0s
Serial   Phase #:21    PDB1 Files: 3     Time: 7s
Restart  Phase #:22    PDB1 Files: 1     Time: 0s
Parallel Phase #:23    PDB1 Files: 23    Time: 104s
Restart  Phase #:24    PDB1 Files: 1     Time: 0s
Parallel Phase #:25    PDB1 Files: 11    Time: 40s
Restart  Phase #:26    PDB1 Files: 1     Time: 0s
Serial   Phase #:27    PDB1 Files: 1     Time: 1s
Restart  Phase #:28    PDB1 Files: 1     Time: 0s
Serial   Phase #:30    PDB1 Files: 1     Time: 0s
Serial   Phase #:31    PDB1 Files: 257   Time: 23s
Serial   Phase #:32    PDB1 Files: 1     Time: 0s
Restart  Phase #:33    PDB1 Files: 1     Time: 1s
Serial   Phase #:34    PDB1 Files: 1     Time: 2s
Restart  Phase #:35    PDB1 Files: 1     Time: 0s
Restart  Phase #:36    PDB1 Files: 1     Time: 1s
Serial   Phase #:37    PDB1 Files: 4     Time: 44s
Restart  Phase #:38    PDB1 Files: 1     Time: 0s
Parallel Phase #:39    PDB1 Files: 13    Time: 67s
Restart  Phase #:40    PDB1 Files: 1     Time: 0s
Parallel Phase #:41    PDB1 Files: 10    Time: 6s
Restart  Phase #:42    PDB1 Files: 1     Time: 0s
Serial   Phase #:43    PDB1 Files: 1     Time: 6s
Restart  Phase #:44    PDB1 Files: 1     Time: 0s
Serial   Phase #:45    PDB1 Files: 1     Time: 1s
Serial   Phase #:46    PDB1 Files: 1     Time: 0s
Restart  Phase #:47    PDB1 Files: 1     Time: 0s
Serial   Phase #:48    PDB1 Files: 1     Time: 140s
Restart  Phase #:49    PDB1 Files: 1     Time: 0s
Serial   Phase #:50    PDB1 Files: 1     Time: 33s
Restart  Phase #:51    PDB1 Files: 1     Time: 0s
Serial   Phase #:52    PDB1 Files: 1     Time: 0s
Restart  Phase #:53    PDB1 Files: 1     Time: 0s
Serial   Phase #:54    PDB1 Files: 1     Time: 38s
Restart  Phase #:55    PDB1 Files: 1     Time: 0s
Serial   Phase #:56    PDB1 Files: 1     Time: 12s
Restart  Phase #:57    PDB1 Files: 1     Time: 0s
Serial   Phase #:58    PDB1 Files: 1     Time: 0s
Restart  Phase #:59    PDB1 Files: 1     Time: 0s
Serial   Phase #:60    PDB1 Files: 1     Time: 0s
Restart  Phase #:61    PDB1 Files: 1     Time: 0s
Serial   Phase #:62    PDB1 Files: 1     Time: 1s
Restart  Phase #:63    PDB1 Files: 1     Time: 0s
Serial   Phase #:64    PDB1 Files: 1     Time: 1s
Serial   Phase #:65    PDB1 Files: 1 Calling sqlpatch [...] Time: 42s
Serial   Phase #:66    PDB1 Files: 1     Time: 1s
Serial   Phase #:68    PDB1 Files: 1     Time: 8s
Serial   Phase #:69    PDB1 Files: 1 Calling sqlpatch [...] Time: 53s
Serial   Phase #:70    PDB1 Files: 1     Time: 91s
Serial   Phase #:71    PDB1 Files: 1     Time: 0s
Serial   Phase #:72    PDB1 Files: 1     Time: 5s
Serial   Phase #:73    PDB1 Files: 1     Time: 0s

------------------------------------------------------
Phases [0-73]         End Time:[2015_12_29 07:35:06]
Container Lists Inclusion:[PDB1] Exclusion:[NONE]
------------------------------------------------------

Grand Total Time: 966s PDB1

LOG FILES: (catupgrdpdb1*.log)

Upgrade Summary Report Located in:
/u01/app/oracle/product/12.1.0.2/cfgtoollogs/CDB2/upgrade/upg_summary.log

Total Upgrade Time:          [0d:0h:16m:6s]

     Time: 969s For PDB(s)

Grand Total Time: 969s

LOG FILES: (catupgrd*.log)

Grand Total Upgrade Time:    [0d:0h:16m:9s]

Even this tiny PDB with very few objects in it took 16 minutes. I have seen this step taking more than 45 minutes on other occasions.

oracle@localhost:/u01/app/oracle/product/12.1.0.2/rdbms/admin$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Tue Dec 29 12:45:36 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> select name,open_mode from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           MOUNTED

SQL> alter pluggable database PDB1 open;

Pluggable database altered.

SQL> @/u01/app/oracle/cfgtoollogs/CDB1/preupgrade/postupgrade_fixups
Post Upgrade Fixup Script Generated on 2015-12-29 07:02:21  Version: 12.1.0.2 Build: 010
Beginning Post-Upgrade Fixups...

**********************************************************************
                     [Post-Upgrade Recommendations]
**********************************************************************

                        *****************************************
                        ******** Fixed Object Statistics ********
                        *****************************************

Please create stats on fixed objects two weeks
after the upgrade using the command:
   EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

^^^ MANUAL ACTION SUGGESTED ^^^


           **************************************************
                ************* Fixup Summary ************

No fixup routines were executed.

           **************************************************
*************** Post Upgrade Fixup Script Complete ********************

PL/SQL procedure successfully completed.

SQL> EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS

PL/SQL procedure successfully completed.

Done! I was using the excellent Pre-Built Virtualbox VM prepared by Roy Swonger, Mike Dietrich and The Database Upgrade Team for this demonstration. Great job guys, thank you for that!
In other words: You can easily test it yourself without having to believe it :-)


Tagged: 12c New Features, Multitenant, upgrade
Categories: DBA Blogs

Full Database Caching in #Oracle 12c

Tue, 2015-12-01 09:43

If your Oracle Database fits into the buffer cache, we will put all segments into it now upon access – no more direct reads:

SQL> connect / as sysdba
Connected.
SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE	12.1.0.2.0	Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production

SQL> select sum(bytes)/1024/1024 as mb from v$datafile;

	MB
----------
      1424

SQL> select current_size from v$buffer_pool;

CURRENT_SIZE
------------
	1872

The requirements are met here, I don’t need to force anything:

SQL> select force_full_db_caching from v$database;

FORCE_FUL
---------
NO

SQL> select bytes/1024/1024 as mb from dba_segments 
     where owner='ADAM' and segment_name='SALES';

	MB
----------
       600

SQL> select count(*) from adam.sales;

  COUNT(*)
----------
  10000000

SQL> show parameter parallel_degree_policy

NAME				     TYPE
------------------------------------ ---------------------------------
VALUE
------------------------------
parallel_degree_policy		     string
MANUAL

The table got accessed once and is now loaded into the buffer cache. PARALLEL_DEGREE_POLICY is on the default MANUAL, remember that.

SQL> connect adam/adam
Connected.
SQL> select name,value from v$mystat natural join v$statname 
     where name in ('physical reads','physical reads direct','session logical reads');

NAME							VALUE
-------------------------------------------------- ----------
session logical reads					   42
physical reads						    0
physical reads direct					    0

SQL> select count(*) from sales;

  COUNT(*)
----------
  10000000

SQL> select name,value from v$mystat natural join v$statname 
     where name in ('physical reads','physical reads direct','session logical reads');

NAME							VALUE
-------------------------------------------------- ----------
session logical reads					75620
physical reads						    0
physical reads direct					    0

Only logical reads, because the table is in the buffer cache. Also for parallel queries:

SQL> select /*+ parallel (sales,4) */ max(amount_sold) from sales;

MAX(AMOUNT_SOLD)
----------------
	    5000

SQL> select * from v$pq_sesstat;

STATISTIC					   LAST_QUERY SESSION_TOTAL	CON_ID
-------------------------------------------------- ---------- ------------- ----------
Queries Parallelized					    1		  1	     0
DML Parallelized					    0		  0	     0
DDL Parallelized					    0		  0	     0
DFO Trees						    1		  1	     0
Server Threads						    4		  0	     0
Allocation Height					    4		  0	     0
Allocation Width					    1		  0	     0
Local Msgs Sent 					  156		156	     0
Distr Msgs Sent 					    0		  0	     0
Local Msgs Recv'd					  156		156	     0
Distr Msgs Recv'd					    0		  0	     0
DOP							    4		  0	     0
Slave Sets						    1		  0	     0

13 rows selected.

SQL> select name,value from v$mystat natural join v$statname 
     where name in ('physical reads','physical reads direct','session logical reads');

NAME							VALUE
-------------------------------------------------- ----------
session logical reads				       152410
physical reads						    0
physical reads direct					    0

SQL> select name,value from v$sysstat where name='physical reads direct';

NAME							VALUE
-------------------------------------------------- ----------
physical reads direct					   21

SQL> select /*+ parallel (sales,4) */ max(amount_sold) from sales;

MAX(AMOUNT_SOLD)
----------------
	    5000

SQL> select name,value from v$sysstat where name='physical reads direct';

NAME							VALUE
-------------------------------------------------- ----------
physical reads direct					   21

Looks like I did In-Memory Parallel Query although PARALLEL_DEGREE_POLICY is on MANUAL, doesn’t it? Just for comparison, I did the same with an 11g version:

SQL> select banner from v$version;

BANNER
-------------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE	11.2.0.3.0	Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production

SQL> select sum(bytes)/1024/1024 as mb from v$datafile;

	MB
----------
      1090

SQL> select current_size from v$buffer_pool;

CURRENT_SIZE
------------
	1200

SQL> select bytes/1024/1024 as mb from dba_segments where owner='ADAM' and segment_name='SALES';

	MB
----------
       528


SQL> select count(*) from adam.sales;

  COUNT(*)
----------
  10000000

SQL> show parameter parallel_degree_policy

NAME				     TYPE			       VALUE
------------------------------------ --------------------------------- ---------
parallel_degree_policy		     string			       MANUAL

SQL> connect adam/adam
Connected.
SQL> select name,value from v$mystat natural join v$statname 
     where name in ('physical reads','physical reads direct','session logical reads');

NAME									    VALUE
---------------------------------------------------------------------- ----------
session logical reads							       26
physical reads									0
physical reads direct								0

SQL> select count(*) from sales;

  COUNT(*)
----------
  10000000

SQL> select name,value from v$mystat natural join v$statname 
     where name in ('physical reads','physical reads direct','session logical reads');

NAME									    VALUE
---------------------------------------------------------------------- ----------
session logical reads							    67465
physical reads								    67433
physical reads direct							    67433

SQL> select /*+ parallel (sales,4) */ max(amount_sold) from sales;

MAX(AMOUNT_SOLD)
----------------
	    5000

SQL> select * from v$pq_sesstat;

STATISTIC				   LAST_QUERY SESSION_TOTAL
------------------------------------------ ---------- -------------
Queries Parallelized				    1		  1
DML Parallelized				    0		  0
DDL Parallelized				    0		  0
DFO Trees					    1		  1
Server Threads					    4		  0
Allocation Height				    4		  0
Allocation Width				    1		  0
Local Msgs Sent 				  116		116
Distr Msgs Sent 				    0		  0
Local Msgs Recv'd				  116		116
Distr Msgs Recv'd				    0		  0

11 rows selected.

SQL> select name,value from v$mystat natural join v$statname 
     where name in ('physical reads','physical reads direct','session logical reads');

NAME									    VALUE
---------------------------------------------------------------------- ----------
session logical reads							   135115
physical reads								   134866
physical reads direct							   134866

As you can see, I got direct reads in 11g for both the serial and the parallel query.
Do not confuse this feature with the In-Memory Option, it is much less sophisticated than that. But it doesn’t come with an extra charge at least :-)


Tagged: 12c New Features, full database caching, Performance Tuning
Categories: DBA Blogs

DOAG annual conference 2015 – great as always!

Fri, 2015-11-27 04:42

Another annual DOAG conference has passed, and I can only say the very best about it: Perfectly organized, large and modern location, impressive list of well known speakers and over 2100 attendees – wow!

DOAG_2015

My presentation Best of RMAN was scheduled at the first slot on the first day, so I was a bit concerned whether many people would attend that early. It turned out that the room got so full that I was asked by the organizers to deliver the same talk again next day – which I happily did, again with a packed room :-)

uwe

Apart from speaking myself, I enjoyed very much to see friends and colleagues again, as well as people I knew from social media before but never met in person yet. Thank you all for your good company guys – I may appear a bit quiet and distanced sometimes, but I really appreciate you and our little conversations. Personal highlight: The lady who approached me at the stairs, shaking hands and telling me that she knew me from an Oracle University class that she liked so much :-)

There were many interesting presentations, just to mention some of those I attended myself:

Frits Hoogland with Oracle Exadata and database memory

Frits

In his very detailed talk, he emphasized the importance of using Huge Pages on Exadata and that MEMORY_TARGET aka Automatic Memory Management is not an option here.

Jonathan Lewis presented Five Hints for Optimising SQL

Jonathan

I’m always amazed how much this man knows and how good he is able to explain it to us mere mortals :-)

Lothar Flatz was presenting Anatomie eines SQL Befehls (how to do Oracle Performance Tuning with a scientific approach)

Lothar

During his very entertaining talk, he quoted no less than seven Oakies (including himself), so that was quite good advertising for the OakTable Network :-)

Frank Schneede delivered Eine Datenbank kommt selten allein (DB Cloning on Exadata using sparse diskgroups)

Frank

while Ulrike Schwinn presented Oracle DB Memory Techniken für mehr Performance (Overview about the meanwhile so many different ways to deal with memory in Oracle)

Ulrike

Couldn’t really catch her because she was running out of the picture all the time :-)

Martin Berger also did an interesting talk: Wie misst Oracle die Verwendung von Database Features? (How to make sense of DBA_FEATURE_USAGE STATISTICS)

Martin

I liked his presentation style with many live demonstrations very much!

My dear colleague Joel Goodman talked about Automatic Parallel Execution

Joel

Joel is what I call a ‘Standup Instructor’ – mention any database related topic and he will be able to deliver an excellent 30 minutes talk about it instantly :-)

A big  THANK YOU to the many people from DOAG who helped to make that event take place again in such an impressive way! Hope to be there again next year.


Tagged: #DOAG2015
Categories: DBA Blogs

Auto optimizer stats after CTAS or direct loads in #Oracle 12c

Thu, 2015-10-29 07:43

Less famous 12c New Feature: If you do Create Table As Select (CTAS) or a direct load into an empty table, we will automatically collect optimizer statistics:

SQL> select banner from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE    12.1.0.2.0      Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production

SQL> create table nu as select * from sales where rownum<=100000; 
Table created.
 
SQL> select num_rows,blocks from user_tables where table_name='NU';

  NUM_ROWS     BLOCKS
---------- ----------
    100000        695

SQL> truncate table nu;
Table truncated.

SQL> insert /*+ append */ into nu  select * from sales where rownum<=200000; 
200000 rows created. 

SQL> commit;
Commit complete.

SQL> select num_rows,blocks from user_tables where table_name='NU';

  NUM_ROWS     BLOCKS
---------- ----------
    200000       1379

If the table is not empty, the statistics are not updated:

SQL> insert /*+ append */ into nu  select * from sales where rownum<=100000; 
100000 rows created. 

SQL> commit;
Commit complete.

SQL> select num_rows,blocks from user_tables where table_name='NU';

  NUM_ROWS     BLOCKS
---------- ----------
    200000       1379

You see that the previous statistics have not been changed here.
If it is a conventional insert:

SQL> truncate table nu; 
Table truncated. 
SQL> insert into nu select * from sales where rownum<=100000; 
100000 rows created. 
SQL> commit; 
Commit complete. 
SQL> select num_rows,blocks from user_tables where table_name='NU'; 
NUM_ROWS BLOCKS 
---------- ---------- 
    200000       1379

Again, the statistics have not been maintained automatically either. Can be done manually still, of course:

SQL> exec dbms_stats.gather_table_stats('ADAM','NU')

PL/SQL procedure successfully completed.

SQL> select num_rows,blocks from user_tables where table_name='NU';

  NUM_ROWS     BLOCKS
---------- ----------
    100000        748

So knowing that, you may be able to skip some manual statistics collections that you may have done in the past after CTAS or bulk loads :-)


Tagged: 12c New Features
Categories: DBA Blogs

Four members of our team are in the Leadership Circle!

Wed, 2015-10-21 02:49

Oracle University Leadership Circle Q1FY16

The recipients of the Oracle University Leadership Circle Quarter 1 Fiscal Year 2016 have just been announced. That is a corporate award for the best instructors worldwide according to customer feedback. Not less than four (!) come from our small team of 14 instructors:

Leadership Circle Recipients Q1FY16

Yes, we have a great team – supported by a great manager: Thank you, Richard! Congratulations to everyone in the circle this time, I feel honored to be listed together with you!

By the way, I never understood why the fiscal year is ahead of the calendar year – suppose you need to study business economics for that ;-)


Categories: DBA Blogs

RMAN old feature: Restore datafile without backup

Tue, 2015-10-20 04:09

Say I have created a new tablespace recently and did not yet take a backup of the datafile. Now I lose that datafile. Dilemma? No, because I can do an ALTER DATABASE CREATE DATAFILE. Sounds complex? Well even if I wouldn’t be aware of that possibility, a simple RMAN restore will work – as if there were a backup:

RMAN> create table adam.nu tablespace tbs1 as select * from adam.sales where rownum<=10000; 
Statement processed 
RMAN> alter system switch logfile;

Statement processed

RMAN> host 'echo kaputt > /u01/app/oracle/oradata/prima/tbs1.dbf';

host command complete

RMAN> select count(*) from adam.nu;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 10/20/2015 11:50:12
ORA-01115: IO error reading block from file  (block # )
ORA-01110: data file 5: '/u01/app/oracle/oradata/prima/tbs1.dbf'
ORA-27072: File I/O error
Additional information: 4
Additional information: 131

RMAN> alter database datafile 5 offline;

Statement processed

RMAN> restore datafile 5;

Starting restore at 2015-10-20 11:50:43
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=187 device type=DISK

creating datafile file number=5 name=/u01/app/oracle/oradata/prima/tbs1.dbf
restore not done; all files read only, offline, or already restored
Finished restore at 2015-10-20 11:50:45

RMAN> recover datafile 5;

Starting recover at 2015-10-20 11:50:52
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:01

Finished recover at 2015-10-20 11:50:53

RMAN> alter database datafile 5 online;

Statement processed

RMAN> select count(*) from adam.nu;

  COUNT(*)
----------
     10000

Cool isn’t it? Requires that you have all archived logs available since the creation of the tablespace. And besides the SQL commands inside the RMAN shell, it is not a 12c new feature. It works that way since forever, as far as I recall. Don’t believe it, test it!  Maybe not on a production system ;-)


Tagged: Backup & Recovery, RMAN
Categories: DBA Blogs