Friday, October 14, 2016

Unclean shutdown detected. for mongod process in Arbiter server

Following messages were received in “/var/log/mongo/mongod.log” of primary server  and other servers of replicatset

Sat Jul 30 02:48:08.631 [rsHealthPoll] couldn't connect to xxx.local:27017: couldn't connect to server xxx.local:27017

Same message was appearing on other arbiter server

when checked on arbiter server no mongod process was running.

[root@xxx ~]# ps -ef| grep mongo
root     10581 10533  0 09:43 pts/0    00:00:00 grep mongo


Starting Mongod process:

When starting mongod process with command “service mongod start”, it encountered following error:

# service mongod start
Starting mongod: about to fork child process, waiting until server is ready for connections.
forked process: 10345
all output going to: /var/log/mongodb/mongod.log
ERROR: child process failed, exited with error number 100


When checking /var/log/mongodb/mongod.log, following was logged.

Fri Oct 14 09:29:41.540 [initandlisten] MongoDB starting : pid=10345 port=27017 dbpath=/data/arb 64-bit host=controller-02
Fri Oct 14 09:29:41.540 [initandlisten] db version v2.4.14
Fri Oct 14 09:29:41.540 [initandlisten] git version: 05bebf9ab15511a71bfbded684bb226014c0a553
Fri Oct 14 09:29:41.540 [initandlisten] build info: Linux ip-10-154-253-119 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Fri Oct 14 09:29:41.540 [initandlisten] allocator: tcmalloc
Fri Oct 14 09:29:41.540 [initandlisten] options: { auth: "true", config: "/etc/mongod.conf", dbpath: "/data/arb", fork: "true", keyFile: "/opt/mongo/key/keyfile1", logappend: "true", logpath: "/var/log/mongodb/mongod.log", nojournal: "true", pidfilepath: "/var/run/mongodb/mongod.pid", port: 27017, replSet: "sitMongoSet", smallfiles: "true" }
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
Fri Oct 14 09:29:41.695 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Fri Oct 14 09:29:41.695 dbexit:
Fri Oct 14 09:29:41.695 [initandlisten] shutdown: going to close listening sockets...
Fri Oct 14 09:29:41.695 [initandlisten] shutdown: going to flush diaglog...
Fri Oct 14 09:29:41.695 [initandlisten] shutdown: going to close sockets...
Fri Oct 14 09:29:41.695 [initandlisten] shutdown: waiting for fs preallocator...
Fri Oct 14 09:29:41.695 [initandlisten] shutdown: closing all files...
Fri Oct 14 09:29:41.696 [initandlisten] closeAllFiles() finished
Fri Oct 14 09:29:41.696 dbexit: really exiting now


It appears mongod process was not cleanly shutdown or server might have rebooted leaving mongodb in unclean state.

Journal was disabled on this Arbiter, so I ran following command to recover the state.
mongod --dbpath /data/arb –repair


After running above command, I again received following errors:

Fri Oct 14 10:09:59.059 [initandlisten] MongoDB starting : pid=11079 port=27017 dbpath=/data/arb 64-bit host=controller-02
Fri Oct 14 10:09:59.060 [initandlisten] db version v2.4.14
Fri Oct 14 10:09:59.060 [initandlisten] git version: 05bebf9ab15511a71bfbded684bb226014c0a553
Fri Oct 14 10:09:59.060 [initandlisten] build info: Linux ip-10-154-253-119 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Fri Oct 14 10:09:59.060 [initandlisten] allocator: tcmalloc
Fri Oct 14 10:09:59.060 [initandlisten] options: { auth: "true", config: "/etc/mongod.conf", dbpath: "/data/arb", fork: "true", keyFile: "/opt/mongo/key/keyfile1", logappend: "true", logpath: "/var/log/mongodb/mongod.log", nojournal: "true", pidfilepath: "/var/lib/mongo/mongod.pid", port: 27017, replSet: "sitMongoSet", smallfiles: "true" }
Fri Oct 14 10:09:59.108 [initandlisten] couldn't open /data/arb/local.ns errno:13 Permission denied
Fri Oct 14 10:09:59.108 [initandlisten] error couldn't open file /data/arb/local.ns terminating
Fri Oct 14 10:09:59.108 dbexit:
Fri Oct 14 10:09:59.108 [initandlisten] shutdown: going to close listening sockets...
Fri Oct 14 10:09:59.108 [initandlisten] shutdown: going to flush diaglog...
Fri Oct 14 10:09:59.108 [initandlisten] shutdown: going to close sockets...
Fri Oct 14 10:09:59.108 [initandlisten] shutdown: waiting for fs preallocator...
Fri Oct 14 10:09:59.108 [initandlisten] shutdown: closing all files...
Fri Oct 14 10:09:59.108 [initandlisten] closeAllFiles() finished
Fri Oct 14 10:09:59.109 [initandlisten] shutdown: removing fs lock...
Fri Oct 14 10:09:59.109 dbexit: really exiting now

It was identified “/data/arb/local.ns” permission was not correct. So I ran following command to correct it (root was the owner)
chown mongod:mongod /data/arb/local.ns

Once above was fixed, mongod process started running fine.

[rsHealthPoll] couldn't connect to xxxxx.local:27017: couldn't connect to server xxxxxx.local:27017

I received following error on mongod.log file of every server of replicaset

[rsHealthPoll] couldn't connect to xxxxx.local:27017: couldn't connect to server xxxxxx.local:27017

When I checked, I discovered one of the arbiter server was not running i.e. mongod process was not running on arbiter server.

Solution: Start the mongod process with either of following command

service mongod start

or


/etc/init.d/mongod start

Once mongod process was started, every server in the replicaset were connected successfully to this arbiter server.

Saturday, June 29, 2013

Some Of Basic Questionnaire For Newly Release Oracle Database 12c


1) What is an Pluggable database really?

Ans-> This is new feature in oracle 12.1 release with respect to database. With this release there is a parent-child relationship between databases. I.e. One database act as Container(Parent) and rest act as its child(Pluggable) databases. We can have n number of pluggable databases for one container database. Container database are the root can contains the Data dictionary as a whole. However pluggable database refer to containers database data dictionary.

Pluggable databases shares some common users with container(ROOT) database like SYS,SYSTEm users.

2) Does my pluggable database contain user datafiles as any other pre-12c database?


Ans-> Pluggable database has its own set of user datafiles and tablespaces



3) Does pluggable database contain Temporary files?

Ans-> Container database holds the temporary file as a whole and all other pluggable database shares those tempfile. But we can create tempfiles for each individual pluggable database


4) Does pluggable database contain UNDO tablespace?

Ans=> No it doesn’t however UNDO tablespace of Container share it with other pluggable database


5) Can we have pluggable database without Container database?


Ans-> No we cannot have pluggable database without Container database.




6) Can container database have no pluggable database?


Ans-> No Container also doesn’t comes without pluggable database. When we install Container database, one implicit SeeD Pluggable database created by default.




7) What is Seed database?


Ans-> Seed database is a pluggable database which comes by default with Container database. Seed database act like a template and can be used to create other non-default pluggable databases




8) Can we remove SeeD database?


Ans-> No we cannot remove it




9) Are there any background processes for Pluggable database like DBWR?


Ans-> No there are no background processes available for pluggable database like we have for any other database. Background process runs for main container database and shares these with pluggable database. So background process like DBWR belongs to container database and do its task to write dirty blocks from SGA to disk. It also writes to user datafiles which belongs to pluggable database




10) Does pluggable database have its SGA and PGA?


Ans-> No Pluggable database doesn’t have its own set of SGA and PGA. However all pluggable database shares the SGA of Container Database. So SGA of container database is shared among other pluggable database




11) Can we create user defined datafiles inside container database?


Ans-> Yes we can create user defined datafiles and tablespaces for container database but its highly recommended not to create any user tablespaces inside CDB bacuse pluggable database purpose is to hold user data




12) Can we use SeeD database for users data?


Ans-> Yes we can use it for user data




13) Do we need separate REDO logs for each pluggable database?


Ans-> No, we cannot create separate REDO logfiles for each pluggable database because REDO belongs to CDB and there is only one set of REDO logs belongs to CDB





14) Does Pluggable database contain controlfiles?


Ans-> No. Controlfiles belongs to CDB only





15) What tablespaces are created by default with Pluggable database?


Ans-> SYSTEM, SYSAUX





16) Do we need separate Listener for each pluggable database


Ans-> There is only one listener.ora file for CDB as a whole. So all other pluggable database uses common listener. Therefore listener.ora and tnsnames.ora reside under CDB




17) Does PDB has alertlog and traces by itself?


Ans-> There is only one alert.log for all PDB which is maintained under CDB. Pluggable database sends message and alerts to CDB’s alert.log






Reference - MOS - FAQ Pluggable database

Create Pluggable database and few other admin stuff on Oracle database 12c

Connecting to CDB(Container database) and Creating my_pdb(pluggable database)


[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.1.0 Production on Tue Apr 2 04:33:48 2013
Copyright (c) 1982, 2012, Oracle.  All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> show parameter db_create
NAME                         TYPE   VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                string
db_create_online_log_dest_1        string
db_create_online_log_dest_2        string
db_create_online_log_dest_3        string
db_create_online_log_dest_4        string
db_create_online_log_dest_5        string

SQL> alter system set db_create_file_dest='/u01/app/oracle/oradata';
System altered.

SQL> desc cdb_pdbs
 Name                            Null?    Type
 ----------------------------------------- -------- ----------------------------
 PDB_ID                          NOT NULL NUMBER
 PDB_NAME                        NOT NULL VARCHAR2(128)
 DBID                            NOT NULL NUMBER
 CON_UID                         NOT NULL NUMBER
 GUID                                   RAW(16)
 STATUS                                 VARCHAR2(13)
 CREATION_SCN                                 NUMBER
 CON_ID                                 NUMBER

SQL> select pdb_name from cdb_pdbs;

PDB_NAME
--------------------------------------------------------------------------------
PDB1
PDB$SEED
PDB2
PDB_RAN




Creating Pluggable database now:

SQL> create pluggable database my_pdb admin user app identified by app roles = (DBA);
Pluggable database created.

Open pluggable database

SQL> alter pluggable database my_pdb open;
Pluggable database altered.

TO confirm the result after pluggable database created, check my_pdb is in NORMAL status

SQL> select
v.Name,
v.Open_Mode,
Nvl(v.Restricted, 'n/a') "Restricted",
d.Status
from v$PDBs v inner join DBA_PDBs d
using (GUID)
order by v.Create_SCN  2    3    4    5    6    7    8  ;

NAME                     OPEN_MODE  Res    STATUS
------------------------------ ---------- --- -------------
PDB$SEED                 READ ONLY  NO       NORMAL
PDB1                     READ WRITE NO      NEEDS SYNC
PDB2                     MOUNTED      n/a     NORMAL
PDB_RAN                  MOUNTED      n/a     NORMAL
MY_PDB                            READ WRITE NO     NORMAL

Also we can check from cdb_pdbs

SQL> select pdb_name from cdb_pdbs;
PDB_NAME
--------------------------------------------------------------------------------
PDB1
PDB$SEED
PDB2
PDB_RAN
MY_PDB

List all datafiles and tempfiles related to all container databases including root and pluggable database with following query

SQL>with Containers as (
select PDB_ID Con_ID, PDB_Name Con_Name from DBA_PDBs
union
select 1 Con_ID, 'CDB$ROOT' Con_Name from Dual)
select
Con_ID,
Con_Name "Con_Name",
Tablespace_Name "T'space_Name",
File_Name "File_Name"
from CDB_Data_Files inner join Containers using (Con_ID)
union
select
Con_ID,
Con_Name "Con_Name",
Tablespace_Name "T'space_Name",
File_Name "File_Name"
from CDB_Temp_Files inner join Containers using (Con_ID)
order by 1, 3
    CON_ID Con_Name   T'space_Name             File_Name
---------- ---------- ------------------------------ --------------------------------------------------
       1 CDB$ROOT   SYSAUX                     /u01/app/oracle/oradata/cdb1/sysaux01.dbf
       1 CDB$ROOT   SYSTEM                     /u01/app/oracle/oradata/cdb1/system01.dbf
       1 CDB$ROOT   TEMP                       /u01/app/oracle/oradata/cdb1/temp01.dbf
       1 CDB$ROOT   UNDOTBS1                   /u01/app/oracle/oradata/cdb1/undotbs01.dbf
       1 CDB$ROOT   USERS                      /u01/app/oracle/oradata/cdb1/users01.dbf
       2 PDB$SEED   SYSAUX                     /u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf
       2 PDB$SEED   SYSTEM                     /u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf
       2 PDB$SEED   TEMP                       /u01/app/oracle/oradata/cdb1/pdbseed/pdbseed_temp0
                                         1.dbf

       3 PDB1       APEX_2594430521661121      /u01/app/oracle/oradata/cdb1/pdb1/APEX_25944305216
                                         61121.dbf

       3 PDB1       EXAMPLE                    /u01/app/oracle/oradata/cdb1/pdb1/example01.dbf
       3 PDB1       SYSAUX                     /u01/app/oracle/oradata/cdb1/pdb1/sysaux01.dbf
       3 PDB1       SYSTEM                     /u01/app/oracle/oradata/cdb1/pdb1/system01.dbf
       3 PDB1       TEMP                       /u01/app/oracle/oradata/cdb1/pdb1/pdb1_temp01.dbf
       3 PDB1       USERS                      /u01/app/oracle/oradata/cdb1/pdb1/SAMPLE_SCHEMA_us
                                         ers01.dbf

       6 MY_PDB     SYSAUX                     /u01/app/oracle/oradata/CDB1/D95A5408497D0AD3E0450
                                         00000000001/datafile/o1_mf_sysaux_8onr8rpw_.dbf

       6 MY_PDB     SYSTEM                     /u01/app/oracle/oradata/CDB1/D95A5408497D0AD3E0450
                                         00000000001/datafile/o1_mf_system_8onr8rmp_.dbf

       6 MY_PDB     TEMP                       /u01/app/oracle/oradata/CDB1/D95A5408497D0AD3E0450
                                         00000000001/datafile/o1_mf_temp_8onrfs2z_.dbf


Rows selected.

Setting the Open_Mode for a PDB:


To open all pluggable database at one(must be from root):

SQL> alter pluggable database all open;

Pluggable database altered.

This statement closes all the PDBs in the CDB:

SQL> alter pluggable database all close;

Pluggable database altered.

When a CDB instance starts up, its PDBs are not automatically opened, so we could create a logon Trigger.


trigger Sys.After_Startup
after startup on database
begin
execute immediate 'alter pluggable database all open';
end After_Startup;



Create PDB as a clone of an existing PDB in the same CDB


[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Tue Apr 2 05:33:50 2013

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


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

SQL> alter pluggable database all open;

Pluggable database altered.
SQL> select pdb_name,status from cdb_pdbs;
SQL> /

PDB_NAME   STATUS
---------- -------------
PDB1     NEEDS SYNC
PDB$SEED   NORMAL
PDB2     NORMAL
PDB_RAN    NORMAL
MY_PDB         NORMAL

Close my_pdb and open in read only mode so that we can make a clone of it

SQL> alter pluggable database my_pdb close;

Pluggable database altered.
SQL> alter pluggable database my_pdb open read only;

Pluggable database altered.

Create a clone

SQL> create pluggable database my_clone from my_pdb;

Pluggable database created.

SQL> alter pluggable database my_pdb close;

Pluggable database altered.

SQL> alter pluggable database my_pdb open;

Pluggable database altered.

SQL> alter pluggable database my_clone open;

Pluggable database altered.

 Unplug My_PDB from cdb1


[oracle@localhost ~]$ . oraenv
ORACLE_SID = [cdb2] ? cdb1
The Oracle base remains unchanged with value /u01/app/oracle
[oracle@localhost ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Tue Apr 2 07:29:41 2013

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


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

SQL> select pdb_name,status from cdb_pdbs;
PDB_NAME   STATUS
---------- -------------
PDB1     NEEDS SYNC
PDB$SEED   NORMAL
PDB2     NORMAL
PDB_RAN    NORMAL
MY_PDB         NORMAL
MY_CLONE   NORMAL

6 rows selected.

SQL> alter pluggable database my_pdb unplug into '/u01/app/oracle/oradata/my_pdb.xml';
alter pluggable database my_pdb unplug into '/u01/app/oracle/oradata/my_pdb.xml'
*
ERROR at line 1:
ORA-65025: Pluggable database MY_PDB is not closed on all instances.


SQL> alter pluggable database my_pdb close immediate;

Pluggable database altered.

SQL> alter pluggable database my_pdb unplug into '/u01/app/oracle/oradata/my_pdb.xml';

Pluggable database altered.

 Hope this helps!

Friday, January 25, 2013

GG checkpoint table error....(ERROR: Could not delete DB checkpoint for REPLICAT..)

Hi All

I'm pretty new to GG technology and learning concepts. But recently while configuring GG on target server i got following error.

ERROR: Could not delete DB checkpoint for REPLICAT REP1 (OCI Error ORA-00942: table or view does not exist (status = 942). Deleting from checkpoint table chktab, group 'REP1', key 2597977681 (0x9ad9fe51), SQL <DELETE FROM chktab  WHERE group_name = 'REP1' AND        group_key  = 2597977681>).

Reason was un know to me.


Here is the Info:


GGSCI (nacssiovm0147) 15> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING
REPLICAT    STOPPED     REP1        00:00:00      17:01:17

GGSCI (nacssiovm0147) 16> delete REPLICAT REP1
ERROR: Could not delete DB checkpoint for REPLICAT REP1 (OCI Error ORA-00942: table or view does not exist (status = 942). Deleting from checkpoint table chktab, group 'REP1', key 2597977681 (0x9ad9fe51), SQL <DELETE FROM chktab  WHERE group_name = 'REP1' AND        group_key  = 2597977681>).


The reason for above error was i added REPLICAT process without specifying NODBCHECKPOINT argument.
So replicat process got created initially, but when i tried to delete this REPLICAT group i got above error.

Solution:
I searched support.oracle.com and fount that we should specify ! argument as well in " delete REPLICAT REP1" command.

For example:

GGSCI (nacssiovm0147) 17> delete REPLICAT REP1 !
WARNING: Could not delete DB checkpoint for REPLICAT REP1 (OCI Error ORA-00942: table or view does not exist (status = 942). Deleting from checkpoint table chktab, group 'REP1', key 2597977681 (0x9ad9fe51), SQL <DELETE FROM chktab  WHERE group_name = 'REP1' AND        group_key  = 2597977681>).


GGSCI (nacssiovm0147) 18> info all

Program     Status      Group       Lag at Chkpt  Time Since Chkpt

MANAGER     RUNNING

Now the REPLICAT process has got delete.

Thanks for checking out and corrections are welcome

Reference- MOS note 965689.1

Saturday, August 4, 2012

Join Cardinality in Oracle 11.2.0.3


Lets take a look upon Join Cardinality which happens when we join two (or more) Table together to get desired result. You might be aware that Cardnilaity for Single Table
for access/filter predicate(no hitograms) comes from Selectivity*num rows. Idea would be same for Join cardinalities as well but there is sight different formula for
Join cardinality.

Formula Looks like:

Join cardinality = Join selectivity * Filtered cardinality of t1.filter * Filtered cardinality of t2.filter

Join selectivity = (numrows(t1) - null(t1.c1)) / numrows(t1) * (numrows(t2) - null(t2.c1)) / numrows(t2) / greater distnct(t1.c1,t2.c1)

Here T1 and T2 are two tables been joined on C1 columns in both tables repectivity.
T1.Filer is Filter aplied on T1 table (if any)
T2.Filer is Filter aplied on T2 table (if any)


Lets take a simple test to check the above formula


create table TAB2 as
select trunc(dbms_random.value(0,5000)) jn,
       trunc(dbms_random.value(0, 40 )) v1,
       rpad('x',100) padding
from all_objects where rownum <= 10000;

create table TAB1 as
select trunc(dbms_random.value(0,4)) jn,
       trunc(dbms_random.value(0, 40 )) v1,
       rpad('x',100) padding
from all_objects where rownum <= 10000;



Gathering stats(witout histograms)

execute dbms_stats.gather_table_stats(ownname=>user,tabname=>'TAB2',method_opt=>'for all columns size 1');
execute dbms_stats.gather_table_stats(ownname=>user,tabname=>'TAB1',method_opt=>'for all columns size 1');


Below are the statistics of both table and its columns(ony required columns)


TABLE_NAME                     NUM_DISTINCT    DENSITY COLUMN_NAME
------------------------------ ------------ ---------- ------------------------------
TAB1                                      4        .25 JN
TAB1                                     40       .025 V1
TAB2                                   4329    .000231 JN
TAB2                                     40       .025 V1


SQL>  select count(*) from tab1, tab2 where tab1.jn=tab2.jn and tab1.v1=1;

  COUNT(*)
----------
       420


Execution Plan
----------------------------------------------------------
Plan hash value: 2043035240

------------------------------------------------------------------------------------
| Id  | Operation                   | Name | Rows  | Bytes | Cost (%CPU)| Time     |
------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT            |      |     1 |    10 |    89   (2)| 00:00:01 |
|   1 |  SORT AGGREGATE             |      |     1 |    10 |            |          |
|*  2 |   HASH JOIN                 |      |   578 |  5780 |    89   (2)| 00:00:01 |
|*  3 |    TABLE ACCESS STORAGE FULL| TAB1 |   250 |  1500 |    44   (0)| 00:00:01 |
|   4 |    TABLE ACCESS STORAGE FULL| TAB2 | 10000 | 40000 |    44   (0)| 00:00:01 |
------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("TAB1"."JN"="TAB2"."JN")
   3 - storage("TAB1"."V1"=1)
       filter("TAB1"."V1"=1)


Statistics
----------------------------------------------------------
         18  recursive calls
          0  db block gets
        348  consistent gets
          0  physical reads
          0  redo size
        527  bytes sent via SQL*Net to client
        524  bytes received via SQL*Net from client
          2  SQL*Net roundtrips to/from client
          4  sorts (memory)
          0  sorts (disk)
          1  rows processed


How come optimizer has assumed the Join selectvity at Line 2 of Explain plan as 578?????

Lets check

Join selectivity = ((10,000 - 0)/10,000 * (10,000 - 0)/10,000) / 4329   --Since 4329 is greater then 4
                 =  1/4329

Join Card =  1/4329*10,000*250 = 577.5 = Rounded to 578 - As expected

So formula seems to work in this condition for 11.2 version of oracle



Lets take a different set of example:

drop table tab1;
drop table tab2;

create table tab1 as
select
trunc(dbms_random.value(0, 500 )) filter,
trunc(dbms_random.value(0, 50 )) jn,
lpad(rownum,10) v1, rpad('x',100) padding
from
all_objects
where
rownum <= 1000;

create table tab2 as
select
trunc(dbms_random.value(0, 500 )) filter,
trunc(dbms_random.value(0, 60 )) jn,
lpad(rownum,10) v1, rpad('x',100) padding
from
all_objects
where
rownum <= 1000;



execute dbms_stats.gather_table_stats(ownname=>user,tabname=>'TAB2',method_opt=>'for all columns size 1');
execute dbms_stats.gather_table_stats(ownname=>user,tabname=>'TAB1',method_opt=>'for all columns size 1');

SQL>  select table_name,num_distinct, density, column_name from dba_tab_columns where table_name in('TAB1','TAB2') and column_name in ('JN','FILTER');

TABLE_NAME                     NUM_DISTINCT    DENSITY COLUMN_NAME
------------------------------ ------------ ---------- ------------------------------
TAB1                                    438 .002283105 FILTER
TAB1                                     50        .02 JN
TAB2                                    441 .002267574 FILTER
TAB2                                     60 .016666667 JN


set autotrace on;
select t1.v1, t2.v1 from tab1 t1,tab2 t2 where t2.jn = t1.jn and t2.filter = 1;

28 rows selected.

Execution Plan
----------------------------------------------------------
Plan hash value: 2953944933

-----------------------------------------------------------------------------------
| Id  | Operation                  | Name | Rows  | Bytes | Cost (%CPU)| Time     |
-----------------------------------------------------------------------------------
|   0 | SELECT STATEMENT           |      |    45 |  1440 |    15   (7)| 00:00:01 |
|*  1 |  HASH JOIN                 |      |    45 |  1440 |    15   (7)| 00:00:01 |
|*  2 |   TABLE ACCESS STORAGE FULL| TAB2 |     2 |    36 |     7   (0)| 00:00:01 |
|   3 |   TABLE ACCESS STORAGE FULL| TAB1 |  1000 | 14000 |     7   (0)| 00:00:01 |
-----------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   1 - access("T2"."JN"="T1"."JN")
   2 - storage("T2"."FILTER"=1)
       filter("T2"."FILTER"=1)


Explain plan says Cardinality of 45??????

Lets confirm

Join Selectivity = 1/50 ( Since there are no nulls on both columns and reason i took 50 on other column despite its smaller then 60 is because Table TAB2 has already fliter on it)

Join Card =  1/50 * 1000 * 2.2 = 44 - (it took 1/50 from tab1 column)

This seems to work too!

References:
J.Lewis Cost-Based Fundamentals
Support.oracle.com

Wednesday, August 1, 2012

Exadata Smart Scan for dbms_stats.auto_sample_size




In this Blog we will see how the DBMS_STATS.GATHER_TABLE_STATS will behave in exadata. Whether this full take full advantage of smart scan capabilities? We will see this in this blog.

rdbms&crs version - 11.2.0.3.0

Before taking and starting about investigation about the Smart Scan, we should bear in mind that following
are the requirements for smart scan to kick in

1) Database must choose Direct path read of its operation
2) Table should have parallel degree defined(if its a small table and satisfying the _small_table_threashold value)
3) If table is large (as defined by _small_table_threashold) then serial direct path read is performed(no parallel degree in this case)
4) Explain plan should have 'STORAGE' word in rowsource operation. For example in non-exadata operation is something like 'Table Access Full' but in Exadata its should be as 'Table Access Storage Full'
5) In Predicate section of Explain Plan, it should have storage clause

Note- Even if above conditions are satisfied, its not guranted smart scan would take place. We will see why this can happen in some cases.

However optimizer is not completely aware about the existence of exadata and direct path read decision is made after optimizer does its job. So there are some heuristics involved when to choose Direct path read operation somethink like segment size,numbers of blocks already in buffer cahceSGA size etc etc.

There is no direct way to check if Smart Scan has happened or not for a query and also how effective the smart scan is, is not known easily. However there are specific performance counters and some wait events for which we can check if a) Smart Scan happened at all or b) how much effective was the SMart scan. So we will use these tow techniques to check smart scan optimization.


I logged in to session and executed below query:
SQL> select s.name,m.value from v$sysstat s,v$mystat m where s.STATISTIC#=m.STATISTIC# and name like '%cell%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell physical IO interconnect bytes                                       0
cell physical IO bytes saved during optimized file creation               0
cell physical IO bytes saved during optimized RMAN file restore           0
cell physical IO bytes eligible for predicate offload                     0
cell physical IO bytes saved by storage index                             0
cell physical IO bytes sent directly to DB node to balance CPU            0
cell smart IO session cache lookups                                       0
cell smart IO session cache hits                                          0
cell smart IO session cache soft misses                                   0
cell smart IO session cache hard misses                                   0
cell smart IO session cache hwm                                           0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell num smart IO sessions in rdbms block IO due to user                  0
cell num smart IO sessions in rdbms block IO due to no cell mem           0
cell num smart IO sessions in rdbms block IO due to big payload           0
cell num smart IO sessions using passthru mode due to user                0
cell num smart IO sessions using passthru mode due to cellsrv             0
cell num smart IO sessions using passthru mode due to timezone            0
cell num smart file creation sessions using rdbms block IO mode           0
cell physical IO interconnect bytes returned by smart scan                0
cell num fast response sessions                                           0
cell num fast response sessions continuing to smart scan                  0
cell statistics spare1                                                    0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell statistics spare2                                                    0
cell statistics spare3                                                    0
cell statistics spare4                                                    0
cell statistics spare5                                                    0
cell statistics spare6                                                    0
cell scans                                                                0
cell blocks processed by cache layer                                      0
cell blocks processed by txn layer                                        0
cell blocks processed by data layer                                       0
cell blocks processed by index layer                                      0
cell commit cache queries                                                 0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell transactions found in commit cache                                   0
cell blocks helped by commit cache                                        0
cell blocks helped by minscn optimization                                 0
chained rows skipped by cell                                              0
chained rows processed by cell                                            0
chained rows rejected by cell                                             0
cell simulated physical IO bytes eligible for predicate offload           0
cell simulated physical IO bytes returned by predicate offload            0
cell CUs sent uncompressed                                                0
cell CUs sent compressed                                                  0
cell CUs sent head piece                                                  0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell CUs processed for uncompressed                                       0
cell CUs processed for compressed                                         0
cell IO uncompressed bytes                                                0
cell index scans                                                          0
cell flash cache read hits                                                0

49 rows selected.

SO there are 49 critical performance counters which can tell us the effiectivnes of smart scan optimization.
As it can be seen all these have zero values since this was fresh login to database(Note we used v%sysstat
and v$mystat, as we are only concern about our session)

SQL> select s.name,m.value from v$sysstat s,v$mystat m where s.STATISTIC#=m.STATISTIC# and name like '%physical%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
physical read total IO requests                                           0
physical read total multi block requests                                  0
physical read requests optimized                                          0
physical read total bytes optimized                                       0
physical read total bytes                                                 0
physical write total IO requests                                          0
physical write total multi block requests                                 0
physical write total bytes                                                0
cell physical IO interconnect bytes                                       0
physical reads                                                            0
physical reads cache                                                      0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
physical read flash cache hits                                            0
physical reads direct                                                     0
physical read IO requests                                                 0
physical read bytes                                                       0
physical writes                                                           0
physical writes direct                                                    0
physical writes from cache                                                0
physical write IO requests                                                0
physical reads direct temporary tablespace                                0
physical writes direct temporary tablespace                               0
physical write bytes                                                      0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
physical writes non checkpoint                                            0
physical reads cache prefetch                                             0
physical reads prefetch warmup                                            0
physical reads retry corrupt                                              0
physical reads direct (lob)                                               0
physical writes direct (lob)                                              0
physical reads for flashback new                                          0
cell physical IO bytes saved during optimized file creation               0
cell physical IO bytes saved during optimized RMAN file restore           0
cell physical IO bytes eligible for predicate offload                     0
cell physical IO bytes saved by storage index                             0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell physical IO bytes sent directly to DB node to balance CPU            0
cell physical IO interconnect bytes returned by smart scan                0
cell simulated physical IO bytes eligible for predicate offload           0
cell simulated physical IO bytes returned by predicate offload            0

37 rows selected.


We wanted to generate the Tracefile for this session

16:06:42 SQL> alter session set tracefile_identifier='tracing_gatherstats';

Session altered.

Elapsed: 00:00:00.00
16:06:57 SQL> alter session Set MAX_DUMP_FILE_SIZE='unlimited';

Session altered.

Elapsed: 00:00:00.00
16:07:04 SQL>
16:07:05 SQL> Alter session set events '10046 trace name context forever, level 12';

Session altered.

Elapsed: 00:00:00.00


From other session we first checked the DEGREE parameter for following table:

SQL> select degree from dba_tables where table_name='ACCT_STATEMENT';

DEGREE
----------------------------------------
         1

-----

Now we run the actual command for which we want to see the Smart Scan:

16:07:20 SQL> exec dbms_stats.gather_table_stats('BOB_PROD_ODS','ACCT_STATEMENT', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size 1');

PL/SQL procedure successfully completed.


Elapsed: 00:03:28.23

Note- We have not used the parallel attribute to cause this job to run in parallel and we have also used
AUTO_SAMPLE_SIZE. This table is around 10GB in size.

Notice the time is took for further references

16:11:22 SQL> select s.name,m.value from v$sysstat s,v$mystat m where s.STATISTIC#=m.STATISTIC# and name like '%cell%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell physical IO interconnect bytes                              6611836928
cell physical IO bytes saved during optimized file creation               0
cell physical IO bytes saved during optimized RMAN file restore           0
cell physical IO bytes eligible for predicate offload                     0
cell physical IO bytes saved by storage index                             0
cell physical IO bytes sent directly to DB node to balance CPU            0
cell smart IO session cache lookups                                       0
cell smart IO session cache hits                                          0
cell smart IO session cache soft misses                                   0
cell smart IO session cache hard misses                                   0
cell smart IO session cache hwm                                           0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell num smart IO sessions in rdbms block IO due to user                  0
cell num smart IO sessions in rdbms block IO due to no cell mem           0
cell num smart IO sessions in rdbms block IO due to big payload           0
cell num smart IO sessions using passthru mode due to user                0
cell num smart IO sessions using passthru mode due to cellsrv             0
cell num smart IO sessions using passthru mode due to timezone            0
cell num smart file creation sessions using rdbms block IO mode           0
cell physical IO interconnect bytes returned by smart scan                0
cell num fast response sessions                                           0
cell num fast response sessions continuing to smart scan                  0
cell statistics spare1                                                    0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell statistics spare2                                                    0
cell statistics spare3                                                    0
cell statistics spare4                                                    0
cell statistics spare5                                                    0
cell statistics spare6                                                    0
cell scans                                                                0
cell blocks processed by cache layer                                      0
cell blocks processed by txn layer                                        0
cell blocks processed by data layer                                       0
cell blocks processed by index layer                                      0
cell commit cache queries                                                 0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell transactions found in commit cache                                   0
cell blocks helped by commit cache                                        0
cell blocks helped by minscn optimization                                 0
chained rows skipped by cell                                              0
chained rows processed by cell                                            0
chained rows rejected by cell                                             0
cell simulated physical IO bytes eligible for predicate offload           0
cell simulated physical IO bytes returned by predicate offload            0
cell CUs sent uncompressed                                                0
cell CUs sent compressed                                                  0
cell CUs sent head piece                                                  0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell CUs processed for uncompressed                                       0
cell CUs processed for compressed                                         0
cell IO uncompressed bytes                                                0
cell index scans                                                          0
cell flash cache read hits                                           803266

49 rows selected.

Some observation made from above:
cell physical IO interconnect bytes is high i.e around 6GB, this means the amount of data flown through
Interconnects which included everything.(including buffer blocks)

cell physical IO bytes eligible for predicate offload is Zero (No smart scan)

cell physical IO bytes saved by storage index is Zero (No Storage index optimization here)

cell physical IO interconnect bytes returned by smart scan is Zero (No Smart scan Optimization)

cell flash cache read hits has non-zero value: (Flash cache helped us a bit)

Conclusion for above result is dbms_stats job didn't get any benefit outof smartscan.
Its time to get the same conclusion from Trace file:


Let check the Tkprof of trace:

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

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        2      0.00       0.00          0          0          0           0
Execute      2      0.09       0.28          0         51        232           1
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        4      0.09       0.29          0         51        232           1

Misses in library cache during parse: 1

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                       3        0.00          0.00
  SQL*Net message from client                     2       33.99         45.55
  SQL*Net break/reset to client                   2        0.00          0.00
  Disk file operations I/O                      940        0.00          0.00
  DFS lock handle                                32        0.10          0.19
  row cache lock                                 40        0.00          0.00
  log file sync                                   1        0.00          0.00


OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse      361      0.02       0.03          0          0          0           0
Execute    697      0.11       0.13         10       2233        806         294
Fetch      360    186.02     207.79     807099    1306746          4         433
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     1418    186.17     207.95     807109    1308979        810         727

Misses in library cache during parse: 4

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        1        0.00          0.00
  enq: TM - contention                            3        0.00          0.00
  gc current block 3-way                         48        0.00          0.00
  Disk file operations I/O                        8        0.00          0.00
  gc current block 2-way                      21477        0.00          1.93
  gc current grant 2-way                          9        0.00          0.00
  cell single block physical read              2103        0.01          1.19
  gc cr block 2-way                              10        0.00          0.00
  gc current grant busy                           1        0.00          0.00
  gc cr multi block request                   17039        0.01          5.89
  gc current block congested                     74        0.00          0.00
  cell multiblock physical read                1223        0.03          1.06
  cell list of blocks physical read            9047        0.05         28.80
  latch: gcs resource hash                        2        0.00          0.00
  latch: gc element                              12        0.00          0.00
  gc cr grant 2-way                              25        0.00          0.00
  gc cr block busy                              115        0.00          0.06
  latch free                                      1        0.00          0.00

    3  user  SQL statements in session.
  233  internal SQL statements in session.
  236  SQL statements in session.
********************************************************************************
From above output also its confirmed that no smart scan happened here, if it were then we could have seen
'Cell smart scan' wait event.
Also notice high waits for 'cell single block physical read' and 'cell list of blocks physical read'
which clearly shows that operation was mostly depend upon the single path access plan.


Let put table in degree of 10 and see the performance(by doing this we are satisfying the requirements for smart
scan)

SQL> alter table bob_prod_ods.ACCT_STATEMENT parallel 10;

Table altered.


SQL*Plus: Release 11.2.0.3.0 Production on Wed Jul 11 16:17:52 2012

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options

SQL> select s.name,m.value from v$sysstat s,v$mystat m where s.STATISTIC#=m.STATISTIC# and name like '%cell%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell physical IO interconnect bytes                                       0
cell physical IO bytes saved during optimized file creation               0
cell physical IO bytes saved during optimized RMAN file restore           0
cell physical IO bytes eligible for predicate offload                     0
cell physical IO bytes saved by storage index                             0
cell physical IO bytes sent directly to DB node to balance CPU            0
cell smart IO session cache lookups                                       0
cell smart IO session cache hits                                          0
cell smart IO session cache soft misses                                   0
cell smart IO session cache hard misses                                   0
cell smart IO session cache hwm                                           0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell num smart IO sessions in rdbms block IO due to user                  0
cell num smart IO sessions in rdbms block IO due to no cell mem           0
cell num smart IO sessions in rdbms block IO due to big payload           0
cell num smart IO sessions using passthru mode due to user                0
cell num smart IO sessions using passthru mode due to cellsrv             0
cell num smart IO sessions using passthru mode due to timezone            0
cell num smart file creation sessions using rdbms block IO mode           0
cell physical IO interconnect bytes returned by smart scan                0
cell num fast response sessions                                           0
cell num fast response sessions continuing to smart scan                  0
cell statistics spare1                                                    0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell statistics spare2                                                    0
cell statistics spare3                                                    0
cell statistics spare4                                                    0
cell statistics spare5                                                    0
cell statistics spare6                                                    0
cell scans                                                                0
cell blocks processed by cache layer                                      0
cell blocks processed by txn layer                                        0
cell blocks processed by data layer                                       0
cell blocks processed by index layer                                      0
cell commit cache queries                                                 0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell transactions found in commit cache                                   0
cell blocks helped by commit cache                                        0
cell blocks helped by minscn optimization                                 0
chained rows skipped by cell                                              0
chained rows processed by cell                                            0
chained rows rejected by cell                                             0
cell simulated physical IO bytes eligible for predicate offload           0
cell simulated physical IO bytes returned by predicate offload            0
cell CUs sent uncompressed                                                0
cell CUs sent compressed                                                  0
cell CUs sent head piece                                                  0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell CUs processed for uncompressed                                       0
cell CUs processed for compressed                                         0
cell IO uncompressed bytes                                                0
cell index scans                                                          0
cell flash cache read hits                                                0

49 rows selected.

Again notice the zero values for critical performance counters:

Setting the trace:
SQL> set time on timing on;
16:18:15 SQL> alter session set tracefile_identifier='tracing_gatherstats_parallel';

Session altered.

Elapsed: 00:00:00.00
16:18:23 SQL> alter session Set MAX_DUMP_FILE_SIZE='unlimited';

Session altered.

Elapsed: 00:00:00.00
16:18:27 SQL> Alter session set events '10046 trace name context forever, level 12';

Session altered.

Elapsed: 00:00:00.00

16:19:00 SQL> exec dbms_stats.gather_table_stats('BOB_PROD_ODS','ACCT_STATEMENT', estimate_percent => dbms_stats.auto_sample_size, method_opt => 'for all columns size 1');

PL/SQL procedure successfully completed.

Elapsed: 00:00:43.31

-wow, did you notice the time difference?
Also note the dbms_stats.auto_sample_size in the job

16:19:57 SQL> select s.name,m.value from v$sysstat s,v$mystat m where s.STATISTIC#=m.STATISTIC# and name like '%cell%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell physical IO interconnect bytes                              5514297160
cell physical IO bytes saved during optimized file creation               0
cell physical IO bytes saved during optimized RMAN file restore           0
cell physical IO bytes eligible for predicate offload            1.0614E+10
cell physical IO bytes saved by storage index                             0
cell physical IO bytes sent directly to DB node to balance CPU            0
cell smart IO session cache lookups                                     146
cell smart IO session cache hits                                        146
cell smart IO session cache soft misses                                  10
cell smart IO session cache hard misses                                   0
cell smart IO session cache hwm                                           0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell num smart IO sessions in rdbms block IO due to user                  0
cell num smart IO sessions in rdbms block IO due to no cell mem           0
cell num smart IO sessions in rdbms block IO due to big payload           0
cell num smart IO sessions using passthru mode due to user                0
cell num smart IO sessions using passthru mode due to cellsrv             0
cell num smart IO sessions using passthru mode due to timezone            0
cell num smart file creation sessions using rdbms block IO mode           0
cell physical IO interconnect bytes returned by smart scan       5507768136
cell num fast response sessions                                           0
cell num fast response sessions continuing to smart scan                  0
cell statistics spare1                                                    0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell statistics spare2                                                    0
cell statistics spare3                                                    0
cell statistics spare4                                                    0
cell statistics spare5                                                    0
cell statistics spare6                                                    0
cell scans                                                              156
cell blocks processed by cache layer                                1428684
cell blocks processed by txn layer                                  1428684
cell blocks processed by data layer                                 1300170
cell blocks processed by index layer                                      0
cell commit cache queries                                                 0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell transactions found in commit cache                                   0
cell blocks helped by commit cache                                        0
cell blocks helped by minscn optimization                           1428684
chained rows skipped by cell                                              0
chained rows processed by cell                                            0
chained rows rejected by cell                                             0
cell simulated physical IO bytes eligible for predicate offload           0
cell simulated physical IO bytes returned by predicate offload            0
cell CUs sent uncompressed                                                0
cell CUs sent compressed                                                  0
cell CUs sent head piece                                                  0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell CUs processed for uncompressed                                       0
cell CUs processed for compressed                                         0
cell IO uncompressed bytes                                       1.0651E+10
cell index scans                                                          0
cell flash cache read hits                                            15209

49 rows selected.

Its time  to explain some the these performance counters(i will cover it detail explanation later)

cell physical IO bytes eligible for predicate offload has around 10GB of value (smart scan if confirmed)

cell physical IO interconnect bytes returned by smart scan has gottan value, this performance counter is the
critical one to know whether smart scan happened or not. Generally the bytes sent back to database node through smart scan is quite low, but in our case its quite high. But one thing we made sure that smart scan has kicked in

cell blocks processed by cache layer
cell blocks processed by txn layer
cell blocks processed by data layer

All above counters got almost same amount of values which means there are 1428684 approx blocks which were processed by smart scan during optimization.(I will cover its details explanation later) These three holds the critical information like how much effective was smart Scan when scanning the blocks.


16:20:44 SQL> select s.name,m.value from v$sysstat s,v$mystat m where s.STATISTIC#=m.STATISTIC# and name like '%physical%';

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
physical read total IO requests                                       15242
physical read total multi block requests                              12540
physical read requests optimized                                      15209
physical read total bytes optimized                              1.0603E+10
physical read total bytes                                        1.0621E+10
physical write total IO requests                                          0
physical write total multi block requests                                 0
physical write total bytes                                                0
cell physical IO interconnect bytes                              5514297160
physical reads                                                      1296460
physical reads cache                                                    797

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
physical read flash cache hits                                            0
physical reads direct                                               1295663
physical read IO requests                                             15242
physical read bytes                                              1.0621E+10
physical writes                                                           0
physical writes direct                                                    0
physical writes from cache                                                0
physical write IO requests                                                0
physical reads direct temporary tablespace                                0
physical writes direct temporary tablespace                               0
physical write bytes                                                      0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
physical writes non checkpoint                                            0
physical reads cache prefetch                                           473
physical reads prefetch warmup                                            0
physical reads retry corrupt                                              0
physical reads direct (lob)                                               0
physical writes direct (lob)                                              0
physical reads for flashback new                                          0
cell physical IO bytes saved during optimized file creation               0
cell physical IO bytes saved during optimized RMAN file restore           0
cell physical IO bytes eligible for predicate offload            1.0614E+10
cell physical IO bytes saved by storage index                             0

NAME                                                                  VALUE
---------------------------------------------------------------- ----------
cell physical IO bytes sent directly to DB node to balance CPU            0
cell physical IO interconnect bytes returned by smart scan       5507768136
cell simulated physical IO bytes eligible for predicate offload           0
cell simulated physical IO bytes returned by predicate offload            0

From above its obvious that any physical read shown here had actually turned into smart scan. Look at
physical read total bytes optimized - which shows how many bytes has either optimized using a)storage index b) flash cache or smart scan.


Let confirm this from Trace file as will. Since we job ran in parallel(degree 10), so we got 10 traces in
trace directory. But we can confirm smart scan only by checking QC and one out of 10 Slave process trace,


Trace file for QC:

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

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        5      0.00       0.00          0          0          0           0
Execute      5      0.08       0.29          0         51        178           1
Fetch        9      0.25       0.25          0          0          0          86
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total       19      0.34       0.56          0         51        178          87

Misses in library cache during parse: 2

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  SQL*Net message to client                      13        0.00          0.00
  SQL*Net message from client                    13       64.43        209.74
  SQL*Net break/reset to client                   2        0.00          0.00
  Disk file operations I/O                      940        0.00          0.00
  DFS lock handle                                32        0.10          0.22
  row cache lock                                 40        0.00          0.00
  log file sync                                   1        0.00          0.00



OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse      196      0.02       0.02          0          0          0           0
Execute    548      0.09       1.78          0       2233        692         238
Fetch      368     27.28      41.20        797      11019          2         445
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total     1112     27.39      43.02        797      13252        694         683

Misses in library cache during parse: 5
Misses in library cache during execute: 1

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  asynch descriptor resize                        1        0.00          0.00
  gc cr block 2-way                              10        0.00          0.00
  gc current block 2-way                        171        0.00          0.02
  enq: TM - contention                            3        0.00          0.00
  gc current block 3-way                        101        0.01          0.03
  Disk file operations I/O                        5        0.00          0.00
  gc current grant busy                           2        0.00          0.00
  gc current block busy                           1        0.00          0.00
  enq: KO - fast object checkpoint                4        0.66          0.66
  reliable message                                1        0.00          0.00
  enq: PS - contention                            3        0.01          0.01
  os thread startup                               8        0.15          0.98
  PX Deq: Join ACK                               10        0.00          0.01
  PX Deq: Parse Reply                            10        0.00          0.00
  PX Deq: Execute Reply                         720        1.06         13.40
  PX Deq: Signal ACK RSG                         10        0.00          0.00
  PX Deq: Signal ACK EXT                         10        0.00          0.01
  PX Deq: Slave Session Stats                    10        0.00          0.00
  gc cr multi block request                    1055        0.00          0.33
  gc cr grant 2-way                              25        0.00          0.00
  cell single block physical read               161        0.00          0.08
  cell list of blocks physical read              81        0.00          0.04
  gc current block congested                      2        0.00          0.00
  cell multiblock physical read                  82        0.00          0.08
  gc cr block busy                               76        0.00          0.04
  enq: HW - contention                            1        0.00          0.00


Observation:
We still see 'cell single block physical read' but this time its very less. There is no 'Cell Smart Scan' in above trace but remember its the slave process job to scan the segments, so would expect this wait events to appear in slave process trace.


Trace file for slave process:

Posting only rel event information:
PARSING IN CURSOR #46950731292240 len=6956 dep=1 uid=84 oct=3 lid=0 tim=1342003755944863 hv=3787614688 ad='76e8e9790' sqlid='079nqsmhw4ug0'
/* SQL Analyze(0) */ select /*+  full(t)    parallel(t,10) parallel_index(t,10) dbms_stats cursor_sharing_exact use_weak_name_resl dynamic_sampling(0) no_monitoring no_substrb_pad  */to_char(count("ACCT_ID")),to_char(substrb(dump(min("ACCT_ID")
----------------------
Above is the very first statement ran by slave processes( i have cut the rest of the lines and only shoed the prefix of this query)
Notice, optimzier has included parallel and Full hint for table segments and for its indexes.

Some initial lines from tracefiles..
END OF STMT
PARSE #46950731292240:c=0,e=120,p=0,cr=0,cu=0,mis=0,r=0,dep=1,og=1,plh=3385837045,tim=1342003755944862
WAIT #47183537774160: nam='Disk file operations I/O' ela= 264 FileOperation=2 fileno=1281 filetype=2 obj#=-1 tim=1342003755961284
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1280 filetype=2 obj#=-1 tim=1342003755961329
WAIT #47183537774160: nam='Disk file operations I/O' ela= 4 FileOperation=2 fileno=1279 filetype=2 obj#=-1 tim=1342003755961346
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1278 filetype=2 obj#=-1 tim=1342003755961360
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1277 filetype=2 obj#=-1 tim=1342003755961377
WAIT #47183537774160: nam='Disk file operations I/O' ela= 5 FileOperation=2 fileno=1276 filetype=2 obj#=-1 tim=1342003755961391
WAIT #47183537774160: nam='Disk file operations I/O' ela= 2 FileOperation=2 fileno=1275 filetype=2 obj#=-1 tim=1342003755961405
WAIT #47183537774160: nam='Disk file operations I/O' ela= 1 FileOperation=2 fileno=1274 filetype=2 obj#=-1 tim=1342003755961426
WAIT #47183537774160: nam='Disk file operations I/O' ela= 2 FileOperation=2 fileno=1273 filetype=2 obj#=-1 tim=1342003755961441
WAIT #47183537774160: nam='Disk file operations I/O' ela= 5 FileOperation=2 fileno=1272 filetype=2 obj#=-1 tim=1342003755961463
WAIT #47183537774160: nam='Disk file operations I/O' ela= 4 FileOperation=2 fileno=1271 filetype=2 obj#=-1 tim=1342003755961487
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1270 filetype=2 obj#=-1 tim=1342003755961505
WAIT #47183537774160: nam='Disk file operations I/O' ela= 5 FileOperation=2 fileno=1269 filetype=2 obj#=-1 tim=1342003755961523
WAIT #47183537774160: nam='Disk file operations I/O' ela= 2 FileOperation=2 fileno=1268 filetype=2 obj#=-1 tim=1342003755961537
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1267 filetype=2 obj#=-1 tim=1342003755961550
WAIT #47183537774160: nam='Disk file operations I/O' ela= 13 FileOperation=2 fileno=1266 filetype=2 obj#=-1 tim=1342003755961578
WAIT #47183537774160: nam='Disk file operations I/O' ela= 10 FileOperation=2 fileno=1265 filetype=2 obj#=-1 tim=1342003755961601
WAIT #47183537774160: nam='Disk file operations I/O' ela= 6 FileOperation=2 fileno=1264 filetype=2 obj#=-1 tim=1342003755961616
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1263 filetype=2 obj#=-1 tim=1342003755961631
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1262 filetype=2 obj#=-1 tim=1342003755961645
WAIT #47183537774160: nam='Disk file operations I/O' ela= 9 FileOperation=2 fileno=1261 filetype=2 obj#=-1 tim=1342003755961662
WAIT #47183537774160: nam='Disk file operations I/O' ela= 4 FileOperation=2 fileno=1260 filetype=2 obj#=-1 tim=1342003755961676
WAIT #47183537774160: nam='Disk file operations I/O' ela= 3 FileOperation=2 fileno=1258 filetype=2 obj#=-1 tim=1342003755961689
WAIT #47183537774160: nam='Disk file operations I/O' ela= 5 FileOperation=2 fileno=1190 filetype=2 obj#=-1 tim=1342003755961706
WAIT #47183537774160: nam='Disk file operations I/O' ela= 1 FileOperation=2 fileno=1189 filetype=2 obj#=-1 tim=1342003755961726
WAIT #47183537774160: nam='Disk file operations I/O' ela= 4 FileOperation=2 fileno=1188 filetype=2 obj#=-1 tim=1342003755961741
WAIT #47183537774160: nam='Disk file operations I/O' ela= 4 FileOperation=2 fileno=1187 filetype=2 obj#=-1 tim=1342003755961777
WAIT #47183537774160: nam='Disk file operations I/O' ela= 10 FileOperation=2 fileno=1186 filetype=2 obj#=-1 tim=1342003755961798
WAIT #47183537774160: nam='Disk file operations I/O' ela= 2 FileOperation=2 fileno=1185 filetype=2 obj#=-1 tim=1342003755
------------------------------
WAIT #46950731292240: nam='PX Deq: Execution Msg' ela= 3990 sleeptime/senderid=268566527 passes=1 p3=31829234640 obj#=-1 tim=1342003755952048
WAIT #46950731292240: nam='cell smart table scan' ela= 171 cellhash#=1170179701 p2=0 p3=0 obj#=75635 tim=1342003755963472
WAIT #46950731292240: nam='cell smart table scan' ela= 151 cellhash#=2167730007 p2=0 p3=0 obj#=75635 tim=1342003755964454
WAIT #46950731292240: nam='cell smart table scan' ela= 138 cellhash#=3675430230 p2=0 p3=0 obj#=75635 tim=1342003755965431
WAIT #46950731292240: nam='cell smart table scan' ela= 132 cellhash#=3883045144 p2=0 p3=0 obj#=75635 tim=1342003755966388
WAIT #46950731292240: nam='cell smart table scan' ela= 156 cellhash#=1423418432 p2=0 p3=0 obj#=75635 tim=1342003755967396
WAIT #46950731292240: nam='cell smart table scan' ela= 122 cellhash#=1731298062 p2=0 p3=0 obj#=75635 tim=1342003755968112
WAIT #46950731292240: nam='cell smart table scan' ela= 122 cellhash#=1557764708 p2=0 p3=0 obj#=75635 tim=1342003755968826
WAIT #46950731292240: nam='cell smart table scan' ela= 141 cellhash#=3126672640 p2=0 p3=0 obj#=75635 tim=1342003755969535
WAIT #46950731292240: nam='cell smart table scan' ela= 181 cellhash#=3737599385 p2=0 p3=0 obj#=75635 tim=1342003755970278
WAIT #46950731292240: nam='cell smart table scan' ela= 118 cellhash#=283595207 p2=0 p3=0 obj#=75635 tim=1342003755971101
WAIT #46950731292240: nam='cell smart table scan' ela= 194 cellhash#=3222317718 p2=0 p3=0 obj#=75635 tim=1342003755971870
WAIT #46950731292240: nam='cell smart table scan' ela= 147 cellhash#=406411811 p2=0 p3=0 obj#=75635 tim=1342003755972587
WAIT #46950731292240: nam='cell smart table scan' ela= 108 cellhash#=2548483693 p2=0 p3=0 obj#=75635 tim=1342003755973309
WAIT #46950731292240: nam='cell smart table scan' ela= 736 cellhash#=1170179701 p2=0 p3=0 obj#=75635 tim=1342003755974470
WAIT #46950731292240: nam='cell smart table scan' ela= 763 cellhash#=2167730007 p2=0 p3=0 obj#=75635 tim=1342003755975271

So we have seen may 'cell smart table scan' in out traces which confirms us that smart scan has happened.
I have cover the reason for seeing too much 'Disk file operations I/O' wait event here.


call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1     12.91      13.13     130372     131275         42           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     12.91      13.13     130372     131275         42           0

Misses in library cache during parse: 0
Optimizer mode: ALL_ROWS
Parsing user id: 84     (recursive depth: 1)
Number of plan statistics captured: 1

Rows (1st) Rows (avg) Rows (max)  Row Source Operation
---------- ---------- ----------  ---------------------------------------------------
         0          0          0  SORT AGGREGATE (cr=0 pr=0 pw=0 time=0 us)
         0          0          0   PX COORDINATOR  (cr=0 pr=0 pw=0 time=0 us)
         0          0          0    PX SEND QC (RANDOM) :TQ10000 (cr=0 pr=0 pw=0 time=0 us)
         1          1          1     SORT AGGREGATE (cr=131275 pr=130372 pw=0 time=13131299 us)
   4040662    4040662    4040662      APPROXIMATE NDV AGGREGATE (cr=131275 pr=130372 pw=0 time=6992899 us cost=39917 size=5126019212 card=40362356)
   4040662    4040662    4040662       PX BLOCK ITERATOR (cr=131275 pr=130372 pw=0 time=2517894 us cost=39917 size=5126019212 card=40362356)
   4040662    4040662    4040662        TABLE ACCESS STORAGE FULL ACCT_STATEMENT (cr=131275 pr=130372 pw=0 time=2201673 us cost=39917 size=5126019212 card=40362356)


Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  PX Deq: Execution Msg                          78        0.37          0.38
  Disk file operations I/O                      677        0.00          0.00
  latch free                                      6        0.00          0.00
  cell smart table scan                         348        0.00          0.15


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

OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        0      0.00       0.00          0          0          0           0
Execute      0      0.00       0.00          0          0          0           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        0      0.00       0.00          0          0          0           0

Misses in library cache during parse: 0

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  latch free                                      1        0.00          0.00
  cell smart table scan                          14        0.00          0.00
  PX Deq: Slave Session Stats                     1        0.00          0.00


OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      0.00       0.00          0          0          0           0
Execute      1     12.91      13.13     130372     131275         42           0
Fetch        0      0.00       0.00          0          0          0           0
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        2     12.91      13.13     130372     131275         42           0

Misses in library cache during parse: 0

Elapsed times include waiting on following events:
  Event waited on                             Times   Max. Wait  Total Waited
  ----------------------------------------   Waited  ----------  ------------
  PX Deq: Execution Msg                          78        0.37          0.38
  Disk file operations I/O                      677        0.00          0.00
  latch free                                      6        0.00          0.00
  cell smart table scan                         348        0.00          0.15

    1  user  SQL statements in session.
    0  internal SQL statements in session.
    1  SQL statements in session.
********************************************************************************
Observation:

1) We saw 'TABLE ACCESS STORAGE FULL ACCT_STATEMENT' in explain plan for query.(which is one of the requirement for smart scan)
2) Cell Smart Scan appeared for 348 times(recursive though). And also 14 times for non recursive query
3) Cell smart scan is the major contribute in wait evens for recursive and non recursive queries.

So trace of slave process also confirm us that smart scan has been used for this job