
The concept of PDB priority has been introduced with Oracle Database 23c. Simply put, it is now possible to define a priority for some or all PDBs inside a CDB, so that the PDBs will open in a specific order, when opening a list of PDBs or all the PDBs of a CDB. More details can be found in the official documentation.
Let’s see how it works!
The CDB JAZZ contains 5 PDBs:
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
_________ ____________ _____________ _____________
2 PDB$SEED READ ONLY NO
4 ARMSTRONG READ WRITE NO
5 BASIE READ WRITE NO
6 CHARLIE READ WRITE NO
7 COUNT READ WRITE NO
8 DUKE READ WRITE NO
With this new feature comes the new column PRIORITY in the dynamic performance view v$pdbs :
SQL> select CON_ID,NAME,OPEN_MODE,OPEN_TIME,PRIORITY from v$pdbs;
CON_ID NAME OPEN_MODE OPEN_TIME PRIORITY
______ ____________ _____________ _______________________________ _______
2 PDB$SEED READ ONLY 28-NOV-23 12.40.23 PM +01:00 1
4 ARMSTRONG READ WRITE 28-NOV-23 01.38.26 PM +01:00
5 BASIE READ WRITE 28-NOV-23 01.41.27 PM +01:00
6 CHARLIE READ WRITE 28-NOV-23 01.41.28 PM +01:00
7 COUNT READ WRITE 28-NOV-23 01.41.44 PM +01:00
8 DUKE READ WRITE 28-NOV-23 01.41.49 PM +01:00
For now, this column is empty (except for PDB$SEED which has priority 1 by default). Let’s set a priority for each of the PDBs, and let’s set the same priority for 2 of them:
SQL> alter pluggable database ARMSTRONG priority 1;
Pluggable database ARMSTRONG altered.
SQL> alter pluggable database BASIE priority 2;
Pluggable database BASIE altered.
SQL> alter pluggable database CHARLIE priority 3;
Pluggable database CHARLIE altered.
SQL> alter pluggable database COUNT priority 3;
Pluggable database COUNT altered.
SQL> alter pluggable database DUKE priority 4;
Pluggable database DUKE altered.
The column PRIORITY in v$pdbs now reflects the changes:
SQL> select CON_ID,NAME,OPEN_MODE,OPEN_TIME,PRIORITY from v$pdbs;
CON_ID NAME OPEN_MODE OPEN_TIME PRIORITY
______ ____________ _____________ _______________________________ _______
2 PDB$SEED READ ONLY 28-NOV-23 12.40.23 PM +01:00 1
4 ARMSTRONG READ WRITE 28-NOV-23 01.38.26 PM +01:00 1
5 BASIE READ WRITE 28-NOV-23 01.41.27 PM +01:00 2
6 CHARLIE READ WRITE 28-NOV-23 01.41.28 PM +01:00 3
7 COUNT READ WRITE 28-NOV-23 01.41.44 PM +01:00 3
8 DUKE READ WRITE 28-NOV-23 01.41.49 PM +01:00 4
When we stop the CDB, and then restart it, the alert log will show that the startup order now complies with the defined priorities:
$ srvctl stop database -d jazz_sky
$ srvctl start database -d jazz_sky
---
2023-11-28T14:08:27.720756+01:00
Completed: Pluggable database ARMSTRONG opened read write
2023-11-28T14:08:30.020670+01:00
Completed: Pluggable database BASIE opened read write
2023-11-28T14:08:32.625920+01:00
Completed: Pluggable database CHARLIE opened read write
2023-11-28T14:08:32.728029+01:00
Completed: Pluggable database COUNT opened read write
2023-11-28T14:08:34.910693+01:00
Completed: Pluggable database DUKE opened read write
---
It is worth noting that when a PDB is cloned, its priority will not be transferred and the corresponding priority column for this PDB will remain unset:
SQL> create pluggable database ARMSTRONG_CLONE from ARMSTRONG keystore identified by "<very_strong_password>" ;
Pluggable database ARMSTRONG_CLONE created.
SQL> select CON_ID,NAME,OPEN_MODE,OPEN_TIME,PRIORITY from v$pdbs;
CON_ID NAME OPEN_MODE OPEN_TIME PRIORITY
______ __________________ _____________ _______________________________ ________
2 PDB$SEED READ ONLY 28-NOV-23 02.08.23 PM +01:00 1
4 ARMSTRONG READ WRITE 28-NOV-23 02.08.25 PM +01:00 1
5 BASIE READ WRITE 28-NOV-23 02.08.27 PM +01:00 2
6 CHARLIE READ WRITE 28-NOV-23 02.08.30 PM +01:00 3
7 COUNT READ WRITE 28-NOV-23 02.08.30 PM +01:00 3
8 DUKE READ WRITE 28-NOV-23 02.08.32 PM +01:00 4
9 ARMSTRONG_CLONE READ WRITE 28-NOV-23 02.25.05 PM +01:00
So when stopping/starting the CDB, this PDB will be opened last:
$ srvctl stop database -d jazz_sky
$ srvctl start database -d jazz_sky
---
2023-11-28T14:26:32.177272+01:00
Completed: Pluggable database ARMSTRONG opened read write
2023-11-28T14:26:34.434415+01:00
Completed: Pluggable database BASIE opened read write
2023-11-28T14:26:36.847798+01:00
Completed: Pluggable database CHARLIE opened read write
2023-11-28T14:26:37.001801+01:00
Completed: Pluggable database COUNT opened read write
2023-11-28T14:26:39.569912+01:00
Completed: Pluggable database DUKE opened read write
2023-11-28T14:26:41.320367+01:00
Completed: Pluggable database ARMSTRONG_CLONE opened read write
---
Then, if priority 1, for example, is defined for this new PDB, it will start more or less at the same time as the other PDB with priority 1, as stated in the documentation “PDBs with the same priority may be processed in any order“:
SQL> alter pluggable database ARMSTRONG_CLONE priority 1;
Pluggable database ARMSTRONG_CLONE altered.
SQL> select CON_ID,NAME,OPEN_MODE,OPEN_TIME,PRIORITY from v$pdbs;
CON_ID NAME OPEN_MODE OPEN_TIME PRIORITY
______ __________________ _____________ _______________________________ ________
2 PDB$SEED READ ONLY 28-NOV-23 02.26.27 PM +01:00 1
4 ARMSTRONG READ WRITE 28-NOV-23 02.26.29 PM +01:00 1
5 BASIE READ WRITE 28-NOV-23 02.26.32 PM +01:00 2
6 CHARLIE READ WRITE 28-NOV-23 02.26.34 PM +01:00 3
7 COUNT READ WRITE 28-NOV-23 02.26.34 PM +01:00 3
8 DUKE READ WRITE 28-NOV-23 02.26.37 PM +01:00 4
9 ARMSTRONG_CLONE READ WRITE 28-NOV-23 02.26.39 PM +01:00 1
$ srvctl stop database -d jazz_sky
$ srvctl start database -d jazz_sky
---
2023-11-28T14:30:14.707150+01:00
Completed: Pluggable database ARMSTRONG_CLONE opened read write
2023-11-28T14:30:14.748263+01:00
Completed: Pluggable database ARMSTRONG opened read write
2023-11-28T14:30:16.879156+01:00
Completed: Pluggable database BASIE opened read write
2023-11-28T14:30:19.426160+01:00
Completed: Pluggable database CHARLIE opened read write
2023-11-28T14:30:19.496366+01:00
Completed: Pluggable database COUNT opened read write
2023-11-28T14:30:21.956247+01:00
Completed: Pluggable database DUKE opened read write
--
This new PDB priority feature in Oracle Database 23c gives control over the startup sequence of PDBs. It ensures critical PDBs will be opened before less vital ones, to reduce the time it takes for critical applications to be accessible.
