BC test:
SQL> select count(*) from sys.dba_tab_statistics where last_analyzed is not null;
COUNT(*)
----------
3610
SQL> EXEC DBMS_STATS.GATHER_DATABASE_STATS;
PL/SQL procedure successfully completed.
SQL> select count(*) from sys.dba_tab_statistics where last_analyzed is not null;
COUNT(*)
----------
3649
SQL> alter session set container=ORCLPDB1;
Session altered.
SQL> select count(*) from sys.dba_tab_statistics where last_analyzed is not null;
COUNT(*)
----------
3507
SQL> EXEC DBMS_STATS.GATHER_DATABASE_STATS;
PL/SQL procedure successfully completed.
SQL> select count(*) from sys.dba_tab_statistics where last_analyzed is not null;
COUNT(*)
----------
3598
B y E Test in my LAB 19C
SQL> select max(last_analyzed) from sys.dba_tab_statistics;
MAX(LAST_ANALYZED)
------------------
14-OCT-24
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBDEV READ WRITE NO
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> EXEC DBMS_STATS.GATHER_DATABASE_STATS;
PL/SQL procedure successfully completed.
SQL> select max(last_analyzed) from sys.dba_tab_statistics;
MAX(LAST_ANALYZED)
------------------
04-NOV-24
SQL> alter session set container=PDBDEV;
Session altered.
SQL> select max(last_analyzed) from sys.dba_tab_statistics;
MAX(LAST_ANALYZED)
------------------
04-NOV-24
SQL>
For option C, the tricky point is the word "only. When connected to CDB$ROOT, you can also collect object statistics at PDB level if specified.
For option D, all containers under the CDB share the same hardware. I can't see why it was incorrect as DBMS_STATS.GATHER_SYSTEM_STATS should be executed at CDB level and applies to the PDBs under it.
BC is correct .https://docs.oracle.com/en/database/oracle/oracle-database/21/arpls/DBMS_STATS.html#GUID-9761DFB9-8710-45D9-9ACE-A4FD37FD69F5
The application PDB user, uses this preference to determine whether to allow the application root to interact with the statics gathering in PDB.
During the statistics gathering of a metadata linked table in the application root, if the statistics in a PDB are in stale state, the application root triggers the statistics gathering for the particular PDB. Using this preference, the user can either execute or ignore the command from the application root.
You can set the following values:
TRUE—Allows the application root trigger the statistics gathering on metadata linked table in application PDB if the statistics on PDB are stale.
FALSE—Ignores the statistics gathering command triggered from application root.
The default value is FALSE.
Note:
CDB root, different from application root, never triggers statistics gathering on the PDBs and it is not controlled by this preference.
B is obvious, also C is true as I've just tested in practice on 19c - EXEC DBMS_STATS.GATHER_DATABASE_STATS launched on CDB$ROOT did NOT calculated stats on PDB1:EMP table I created.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 HR READ WRITE NO
SQL> alter session set container = PDB$SEED;
Session altered.
SQL> show con_name
CON_NAME
------------------------------
PDB$SEED
SQL> select count(*) from sys.dba_tab_statistics where last_analyzed is not null;
COUNT(*)
----------
2290
SQL> EXEC DBMS_STATS.GATHER_DATABASE_STATS;
BEGIN DBMS_STATS.GATHER_DATABASE_STATS; END;
*
ERROR at line 1:
ORA-20000: database or pluggable database open for read-only access
ORA-06512: at "SYS.DBMS_STATS", line 42559
ORA-06512: at "SYS.DBMS_STATS", line 42521
ORA-06512: at "SYS.DBMS_STATS_INTERNAL", line 17263
ORA-06512: at "SYS.DBMS_STATS", line 42414
ORA-06512: at "SYS.DBMS_STATS", line 42549
ORA-06512: at line 1
corect BC
tested on 19c and 12.2
test provided by ald85 is not accurate, E is not corect
try creating simple tales in ROOT and PDB than gather db stats from
ROOT, and you will see that PDB tables stats will not be gathered.
A voting comment increases the vote count for the chosen answer by one.
Upvoting a comment with a selected answer will also increase the vote count towards that answer by one.
So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.
antoniomariano1983
Highly Voted 2 years, 7 months agoABAJ
Highly Voted 3 years, 7 months agofiko666
3 years agocujar2003
Most Recent 2 months, 1 week agoGuhborges
1 year, 6 months agoAlvinzzz
1 year, 7 months agoScottL
1 year, 8 months ago_gio_
1 year, 8 months agojareach
1 year, 11 months agoKushal22
1 year, 12 months agochefdba
3 years, 2 months agorashedptdba
3 years, 3 months agoNeil107
3 years, 5 months agonavingupta52
3 years, 6 months agoObserverPL
3 years, 7 months agocerebro2000x
4 years, 5 months agojanw
4 years, 5 months agodacoben415lywenw
4 years, 6 months ago