Pages

Thursday, October 25, 2018

Large Trace Files with Error: ORA-00600: internal error code, arguments: [ktspfupdst-1]. Rebuild Indexes.

===============================
General
===============================
Large trace file are generated from time to time.

===============================
Evidences
===============================
less /software/oracle/diag/rdbms/orainst/orainst/trace/alert_orainst.log 

Wed Oct 24 02:31:15 2018
Errors in file /software/oracle/diag/rdbms/orainst/orainst/trace/orainstorainst_ora_28448.trc  (incident=79868):
ORA-00600: internal error code, arguments: [ktspfupdst-1], [], [], [], [], [], [], [], [], [], [], []
Incident details in: /software/oracle/diag/rdbms/orainst/orainst/incident/incdir_79868/orainst_ora_28448_i79868.trc
Wed Oct 24 02:31:17 2018
Trace dumping is performing id=[cdmp_20181024023117]

less /software/oracle/diag/rdbms/orainst/orainst/incident/incdir_79868/orainst_ora_28448_i79868.trc

Dump file /software/oracle/diag/rdbms/orainst/orainst/incident/incdir_79868/orainst_ora_28448_i79868.trc
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
ORACLE_HOME = /software/oracle/111
System name:    Linux
Node name:      col-com-1-aps-4
Release:        2.6.18-308.24.1.el5
Version:        #1 SMP Wed Nov 21 11:42:14 EST 2012
Machine:        x86_64
Instance name: orainst
Redo thread mounted by this instance: 1
Oracle process number: 83
Unix process pid: 28448, image: oracle@col-com-1-aps-4


*** 2018-10-24 02:31:15.971
*** SESSION ID:(488.25914) 2018-10-24 02:31:15.971
*** CLIENT ID:() 2018-10-24 02:31:15.971
*** SERVICE NAME:(SYS$USERS) 2018-10-24 02:31:15.971
*** MODULE NAME:(JDBC Thin Client) 2018-10-24 02:31:15.971
*** ACTION NAME:() 2018-10-24 02:31:15.971

Dump continued from file: /software/oracle/diag/rdbms/orainst/orainst/trace/orainst_ora_28448.trc
ORA-00600: internal error code, arguments: [ktspfupdst-1], [], [], [], [], [], [], [], [], [], [], []

========= Dump for incident 79868 (ORA 600 [ktspfupdst-1]) ========

*** 2018-10-24 02:31:15.971
----- Current SQL Statement for this session (sql_id=akh1m5g2waych) -----
MERGE into SFI_CUSTOMER_PROFILE o using (select :1  KEY1 from dual) o1 on (o.KEY1 = o1.KEY1) when matched then update  SET IMSI=:2 , TS_LAST_MODIFIED=sysdate, KEY2=:3 , KEY3=:4 , MSISDN=:5 , ATTR41=:6 , ATTR42=:7 , ATTR43=:8 , ATTR44=:9 , ATTR45=:10 ,  ATTR46=:11 , ATTR47=:12 , ATTR48=:13 , ATTR49=:14 , ATTR50=:15 ,  ATTR51=:16 , ATTR52=:17 , ATTR53=:18 , ATTR54=:19 , ATTR55=:20 ,  ATTR56=:21 , ATTR57=:22 , ATTR58=:23 , ATTR59=:24 , ATTR60=:25 ,  ATTR61=:26 , ATTR62=:27 , ATTR63=:28 , ATTR64=:29 , ATTR65=:30 ,  ATTR66=:31 , ATTR67=:32 , ATTR68=:33 , ATTR69=:34 , ATTR70=:35 ,  ATTR71=:36 , ATTR72=:37 , ATTR73=:38 , ATTR74=:39 , ATTR75=:40 ,  ATTR76=:41 , ATTR77=:42 , ATTR78=:43 , ATTR79=:44 , ATTR80=:45 ,  TS_LAST_TRY_FETCH=:46 , EI_STATUS_CODE_ID=:47   when not matched then  Insert (o.KEY1, o.IMSI, o.TS_LAST_MODIFIED,o.KEY2,o.KEY3, o.MSISDN, o.ATTR41,o.ATTR42,o.ATTR43,o.ATTR44,o.ATTR45,  o.ATTR46,o.ATTR47,o.ATTR48,o.ATTR49,o.ATTR50, o.ATTR51,o.ATTR52,o.ATTR53,o.ATTR54,o.ATTR55, o.ATTR56,o.ATTR57,o.ATTR58,o.ATTR59,o.ATTR60, o.ATTR61,o.ATTR62,o.ATTR63,o.ATTR64,o.ATTR65, o.ATTR66,o.ATTR67,o.ATTR68,o.ATTR69,o.ATTR70, o.ATTR71,o.ATTR72,o.ATTR73,o.ATTR74,o.ATTR75,  o.ATTR76,o.ATTR77,o.ATTR78,o.ATTR79,o.ATTR80, o.TS_LAST_TRY_FETCH,o.EI_STATUS_CODE_ID) Values (:48 ,:49 ,sysdate,:50 ,:51 ,:52 ,:53 ,:54 ,:55 ,:56 ,:57 ,:58 ,:59 ,:60 ,:61 ,:62 ,:63 ,:64 ,:65 ,:66 ,:67 ,:68 ,:69 ,:70 ,:71 ,:72 ,:73 ,:74 ,:75 ,:76 ,:77 ,:78 ,:79 ,:80 ,:81 ,:82 ,:83 ,:84 ,:85 ,:86 ,:87 ,:88 ,:89 ,:90 ,:91 ,:92 ,:93 ,:94 )


===============================
Solution
===============================
Searching for ORA-00600: internal error code, arguments: [ktspfupdst-1], [], [], [], [], [], [], [], [], [], [], [] 

Reading the Matalink description, is seems that the  issue is related to DML operations on a table with corrupt Index.

Indeed, in this case, trace files were generated during MERGE statement.

Per Matalink, two possible solutions

1st Solution
A. Rebuilding all indexes on the updated table, and it partitions.

B. Running DBMS_SPACE_ADMIN.assm_segment_verify();

DBMS_SPACE_ADMIN.ASSM_SEGMENT_VERIFY example
BEGIN
  DBMS_SPACE_ADMIN.ASSM_SEGMENT_VERIFY ('PERFSTAT','STATS$EVENT_HISTOGRAM', 'TABLE', NULL, 10);
  END;
/
PL/SQL procedure successfully completed.

PERFSTAT - owner
STATS$EVENT_HISTOGRAM - object name
TABLE - object type
NULL - partition name
10 - stands for SEGMENT_VERIFY_DEEP - Deep verification involves consistency checks between datablocks and space metadata blocks
9 - stands for SEGMENT_VERIFY_BASIC - Basic verification involves consistency checks of space metadata.



2nd Solution
A. ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;

B. In case of error: rebuilding all indexes on the updated table, and it partitions. then validate structure with same command.

C. ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;

===============================
1st Solution
===============================

For Non Partitioned Tables:

SELECT 'ALTER INDEX '||table_owner||'.'||index_name||' REBUILD ONLINE ;' 
  FROM DBA_INDEXES 
 WHERE index_name IN 
      (SELECT index_name 
         FROM USER_INDEXES 
        WHERE table_name = 'SFI_CUSTOMER_PROFILE')
   AND index_owner = 'MY_USER';


For Partitions:

SELECT 'ALTER INDEX '||index_owner||'.'||index_name||' REBUILD PARTITION '||partition_name||';' 
  FROM DBA_IND_PARTITIONS 
 WHERE index_name IN 
       (SELECT index_name 
          FROM USER_PART_INDEXES 
         WHERE  table_name = 'SFI_CUSTOMER_PROFILE')
   AND index_owner = 'MY_USER';

===============================
2nd Solution by Example
===============================

sqlplus system/XXX@orainst

Several users own table SFI_CUSTOMER_PROFILE
For all except one, the command is successful.

SELECT 'ANALYZE TABLE '||owner||'.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE ONLINE;'
FROM  DBA_SEGMENTS WHERE segment_name = 'SFI_CUSTOMER_PROFILE' AND blocks > 10;


SQL> ANALYZE TABLE USER_A.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE ONLINE;
Table analyzed.

SQL> ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE ONLINE;
ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE ONLINE
*
ERROR at line 1:
ORA-14508: specified VALIDATE INTO table not found

Need to use syntax:
ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;

To create the table INVALID_ROWS:

@/software/oracle/111/rdbms/admin/utlvalid.sql


oracle@user:~/scripts>% less /software/oracle/111/rdbms/admin/utlvalid.sql

rem 
Rem  Copyright (c) 1990, 1995, 1996, 1998 by Oracle Corporation
Rem  NAME
REM  UTLVALID.SQL
Rem  FUNCTION
Rem    Creates the default table for storing the output of the
Rem    analyze validate command on a partitioned table
Rem  NOTES
Rem  MODIFIED
Rem     syeung     06/17/98 - add subpartition_name                            
Rem     mmonajje   05/21/96 - Replace timestamp col name with analyze_timestamp
Rem     sbasu      05/07/96 - Remove echo setting
Rem     ssamu      01/09/96 - new file utlvalid.sql
Rem

create table INVALID_ROWS (
  owner_name         varchar2(30),
  table_name         varchar2(30),
  partition_name     varchar2(30),
  subpartition_name  varchar2(30),
  head_rowid         rowid,
  analyze_timestamp  date
);


SQL> ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;
ANALYZE TABLE COL_CLARO_SPXQQ.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS
*
ERROR at line 1:
ORA-01499: table/index cross reference failure - see trace file


To locate the trace file
SQL> ALTER SESSION SET TRACEFILE_IDENTIFIER = 'ALEC.DBA';

SQL> ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;

 Trace file:
 /software/oracle/diag/rdbms/orainst/orainst/trace/orainst_ora_21706_ALEC.DBA
 *** 2019-05-12 08:10:20.401
*** SESSION ID:(528.12704) 2019-05-12 08:10:20.401
*** CLIENT ID:() 2019-05-12 08:10:20.401
*** SERVICE NAME:(orainst) 2019-05-12 08:10:20.401
*** MODULE NAME:(SQL*Plus) 2019-05-12 08:10:20.401
*** ACTION NAME:() 2019-05-12 08:10:20.401

Table/Index row count mismatch1?RAaDG~ODU

table 449980 : index 449979, 0
Partitioned Index root = tsn: 5 rdba: 0x0140843a


The root cause of failure is mismatch in rows between table and primary key index.
This is not a valid situation.


SQL> SELECT index_name FROM DBA_PART_INDEXES WHERE table_name = 'SFI_CUSTOMER_PROFILE' AND owner = 'USER_B';

INDEX_NAME
------------------------------
SFI_CUSTOMER_PROFILE_PK



SQL> SELECT 'ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION '||partition_name||' ONLINE; '
FROM DBA_IND_PARTITIONS 
WHERE index_name = 'SFI_CUSTOMER_PROFILE_PK' 
AND index_owner = 'USER_B';


ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P69 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P70 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P71 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P72 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P73 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P74 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P75 ONLINE;
ALTER INDEX USER_B.SFI_CUSTOMER_PROFILE_PK REBUILD PARTITION SYS_P76 ONLINE;


SQL> ALTER SESSION SET TRACEFILE_IDENTIFIER = 'ALEC.DBA_2';

SQL> ANALYZE TABLE COL_CLARO_SPXQQ.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;
ANALYZE TABLE COL_CLARO_SPXQQ.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS
*
ERROR at line 1:
ORA-01499: table/index cross reference failure - see trace file

SQL> SELECT COUNT(*) FROM INVALID_ROWS;

  COUNT(*)
----------
         0
 
 
Trace file: /software/oracle/diag/rdbms/orainst/orainst/trace/orainst_ora_21706_ALEC.DBA_2
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
ORACLE_HOME = /software/oracle/111
System name:    Linux
Node name:      col-com-1-aps-3
Release:        2.6.18-308.24.1.el5
Version:        #1 SMP Wed Nov 21 11:42:14 EST 2012
Machine:        x86_64
Instance name: orainst
Redo thread mounted by this instance: 1
Oracle process number: 38
Unix process pid: 21706, image: oracle@col-com-1-aps-3


*** 2019-05-12 08:20:50.739
*** SESSION ID:(528.12704) 2019-05-12 08:20:50.739
*** CLIENT ID:() 2019-05-12 08:20:50.739
*** SERVICE NAME:(orainst) 2019-05-12 08:20:50.739
*** MODULE NAME:(SQL*Plus) 2019-05-12 08:20:50.739
*** ACTION NAME:() 2019-05-12 08:20:50.739


*** TRACE CONTINUED FROM FILE /software/oracle/diag/rdbms/orainst/orainst/trace/orainst_ora_21706_ALEC.KAPLAN ***

Table/Index row count mismatch1?1rEN5~2FU

table 449990 : index 449989, 0
Partitioned Index root = tsn: 5 rdba: 0x0140c5b2
orainst_ora_21706_ALEC.KAPLAN_2 (END)  


Same error as before...
The rebuild of index did not solve error.
This is the index in question:

ALTER TABLE SFI_CUSTOMER_PROFILE
ADD CONSTRAINT SFI_CUSTOMER_PROFILE_PK PRIMARY KEY (key1) 
USING INDEX LOCAL;

Lets TRUNCATE the table, and re-populate is from a backup table.
  
CREATE TABLE SFI_CUSTOMER_PROFILE_BAK AS SELECT * FROM SFI_CUSTOMER_PROFILE WHERE 1=2;
ALTER TABLE SFI_CUSTOMER_PROFILE_BAK NOLOGGING;
INSERT /*+ APPEND */ INTO SFI_CUSTOMER_PROFILE_BAK SELECT * FROM SFI_CUSTOMER_PROFILE;
3593549 rows created.
TRUNCATE TABLE SFI_CUSTOMER_PROFILE;
INSERT /*+ APPEND */ INTO SFI_CUSTOMER_PROFILE SELECT * FROM SFI_CUSTOMER_PROFILE_BAK;

COMMIT;

   
SQL> ANALYZE TABLE USER_B.SFI_CUSTOMER_PROFILE VALIDATE STRUCTURE CASCADE INTO INVALID_ROWS;

Table analyzed.

Now table data and table PK are in sync.

Need to drop the INVALID_ROWS table:
   
SQL> DROP TABLE INVALID_ROWS;
Table dropped.   

Wednesday, October 24, 2018

Large Trace Files with Error: ORA-08102: index key not found, obj# 9999, file 99 block 99999

========================================
General
========================================
Large trc files are being generated.

========================================
Evidences
========================================


alert.log
========================================
Wed Oct 24 05:48:16 2018
Trace dumping is performing id=[cdmp_20181024054816]
Wed Oct 24 05:49:24 2018
Errors in file /software/oracle/diag/rdbms/igt/igt/trace/igt_j000_12354.trc:
ORA-12012: error on auto execute of job 141
ORA-08102: index key not found, obj# 282, file 1, block 1969 (2)
Errors in file /software/oracle/diag/rdbms/igt/igt/trace/igt_j000_12354.trc:
ORA-12012: error on auto execute of job 141
ORA-08102: index key not found, obj# 282, file 1, block 1969 (2)
Wed Oct 24 05:49:25 2018
Trace dumping is performing id=[cdmp_20181024054925]
Wed Oct 24 05:50:33 2018
Errors in file /software/oracle/diag/rdbms/igt/igt/trace/igt_j000_12354.trc:
ORA-00604: error occurred at recursive SQL level 1
ORA-08102: index key not found, obj# 282, file 1, block 1969 (2)
ORA-12012: error on auto execute of job 141
ORA-08102: index key not found, obj# 282, file 1, block 1969 (2)
Wed Oct 24 05:51:32 2018


/software/oracle/diag/rdbms/igt/igt/trace/igt_j000_12354.trc
========================================
Trace file /software/oracle/diag/rdbms/igt/igt/trace/igt_j000_12354.trc
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
ORACLE_HOME = /software/oracle/111
System name:    Linux
Node name:      col-com-1-aps-4
Release:        2.6.18-308.24.1.el5
Version:        #1 SMP Wed Nov 21 11:42:14 EST 2012
Machine:        x86_64
Instance name: igt
Redo thread mounted by this instance: 1
Oracle process number: 69
Unix process pid: 12354, image: oracle@col-com-1-aps-4 (J000)


*** 2018-10-24 05:50:30.185
*** SESSION ID:(462.12791) 2018-10-24 05:50:30.185
*** CLIENT ID:() 2018-10-24 05:50:30.185
*** SERVICE NAME:(SYS$USERS) 2018-10-24 05:50:30.185
*** MODULE NAME:() 2018-10-24 05:50:30.185
*** ACTION NAME:() 2018-10-24 05:50:30.185


*** TRACE FILE RECREATED AFTER BEING REMOVED ***


REDO RECORD - Thread:1 RBA: 0x0193ac.0001b6c7.0084 LEN: 0x15638 VLD: 0x09
SCN: 0x0db7.14fe2926 SUBSCN:  1 10/24/2018 05:42:57
CHANGE #1 TYP:2 CLS: 1 AFN:4 DBA:0x01017022 OBJ:153442 SCN:0x0db7.14fe27f4 SEQ:  1 OP:11.4 ENC:0
KTB Redo 
op: 0x01  ver: 0x01  
compat bit: 4 (post-11) padding: 1
op: F  xid:  0x000d.00f.0002be51    uba: 0x00c02523.1ef7.25
KDO Op code: LKR row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x01017022  hdba: 0x010073e2
itli: 2  ispac: 0  maxfr: 4858
tabn: 0 slot: 7 to: 2
CHANGE #2 TYP:0 CLS:41 AFN:3 DBA:0x00c00140 OBJ:4294967295 SCN:0x0db7.14fe277e SEQ:  2 OP:5.2 ENC:0
ktudh redo: slt: 0x000f sqn: 0x0002be51 flg: 0x0012 siz: 136 fbi: 0
            uba: 0x00c02523.1ef7.25    pxid:  0x0000.000.00000000
CHANGE #3 TYP:2 CLS: 1 AFN:4 DBA:0x0104f5c5 OBJ:153442 SCN:0x0db7.14a89d05 SEQ:  1 OP:11.5 ENC:0
KTB Redo 
op: 0x11  ver: 0x01  
compat bit: 4 (post-11) padding: 1
op: F  xid:  0x000d.00f.0002be51    uba: 0x00c02524.1ef7.01
Block cleanout record, scn:  0x0db7.14fe291b ver: 0x01 opt: 0x02, entries follow...
  itli: 6  flg: 2  scn: 0x0db7.14a89d05
KDO Op code: URP row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x0104f5c5  hdba: 0x010073e2
itli: 1  ispac: 0  maxfr: 4858
tabn: 0 slot: 0(0x0) flag: 0x0c lock: 1 ckix: 0
ncol: 42 nnew: 41 size: 0
col  0: [15]  37 33 32 31 30 31 31 37 30 39 34 32 35 30 34
col  2: [ 2]  c1 02
col  3: [ 2]  c1 02
col  4: [ 1]  80
col 41: [ 1]  80
CHANGE #83 TYP:0 CLS:26 AFN:3 DBA:0x00c1461c OBJ:4294967295 SCN:0x0db7.1511b877 SEQ:  7 OP:5.1 ENC:0
ktudb redo: siz: 84 spc: 4636 flg: 0x0022 seq: 0xfee7 rec: 0x08
            xid:  0x0005.004.0004e55f  
ktubu redo: slt: 4 rci: 7 opc: 11.1 objn: 43448 objd: 153442 tsn: 4
Undo type:  Regular undo       Undo type:  Last buffer split:  No 
Tablespace Undo:  No 
             0x00000000
KDO undo record:
KTB Redo 
op: 0x04  ver: 0x01  
compat bit: 4 (post-11) padding: 1
op: L  itl: xid:  0x000e.01b.0002b70d uba: 0x00c0df2a.1f14.08
                      flg: C---    lkc:  0     scn: 0x0db7.140c0dc8
KDO Op code: LKR row dependencies Disabled
  xtype: XA flags: 0x00000000  bdba: 0x03014003  hdba: 0x010073e2
itli: 2  ispac: 0  maxfr: 4858
tabn: 0 slot: 8 to: 0
END OF DUMP REDO

*** 2018-10-24 05:50:33.287
ORA-00604: error occurred at recursive SQL level 1
ORA-08102: index key not found, obj# 282, file 1, block 1969 (2)
ORA-12012: error on auto execute of job 141
ORA-08102: index key not found, obj# 282, file 1, block 1969 (2)

========================================
Resolution
========================================

SQL> SELECT OWNER, OBJECT_NAME, SUBOBJECT_NAME, OBJECT_TYPE 
       FROM DBA_OBJECTS 
      WHERE OBJECT_ID = '282';

OWNER OBJECT_NAME SUBOBJECT_NAME OBJECT_TYPE
------- ----------- -------------- --------------
SYS     I_JOB_NEXT                 INDEX


sqlplus / as sysdba
ALTER INDEX SYS.I_JOB_NEXT REBUILD ONLINE;




Tuesday, October 23, 2018

expdp estimate size for exported segments

==============================
General
==============================

Getting estimation for the size of exported segments before running expdp command.

Note, that when doing estimate, no dmp file is generated.

==============================
Estimate size for export file.
==============================
Syntax for getting estimate:
expdp user/pass@orainst directory=IG_EXP_DIR LOGFILE=test_exp.log estimate=BLOCKS ESTIMATE_ONLY=Y 
or
expdp user/pass@orainst directory=IG_EXP_DIR LOGFILE=test_exp.log estimate=STATISTICS ESTIMATE_ONLY=Y 

ESTIMATE_ONLY 
A parameter that tells expdp process to skip actual export, and only to estimate the size.
Values: Y/N
Default=N

ESTIMATE
Method to estimate the size of a segment. 
Values: BLOCKS/STATISTICS
Default: BLOCKSNumber of segment blocks * block size.



==============================
The Test
==============================

Same schema was tested with expdp estimate only
A. No up to date statistics, estimate=BLOCKS
B.  No up to date statistics, estimate=STATISTICS 
C. Gather DBMS_STATS for main three tables in the system
D. Up to date statistics, estimate=BLOCKS
E. Up to date statistics, estimate=STATISTICS 

==============================
The Results
==============================
A. No up to date statistics, estimate=BLOCKS


my_user@my_server:~/workarea/ora_exp>% less test_exp.log
Copyright (c) 2003, 2007, Oracle.  All rights reserved.
;;; 
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
Starting "user"."SYS_EXPORT_SCHEMA_01":  user/********@igt directory=IG_EXP_DIR LOGFILE=test_exp.log estimate=BLOCKS ESTIMATE_ONLY=Y 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   2.187 GB
.  estimated "user"."SGA_SUBSCRIBER_SFI"       2.127 GB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  1.781 GB
.  estimated "user"."SGA_W_IPN_SUBSCRIBER"       608 MB
.  estimated "user"."SUBSCRIBER_USAGE_INFO"      424 MB
.  estimated "user"."TAP_TEMP"                   256 MB


B.  No up to date statistics, estimate=STATISTICS 
Export: Release 11.1.0.7.0 - 64bit Production on Tuesday, 23 October, 2018 18:06:53

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
;;; 
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
Starting "user"."SYS_EXPORT_SCHEMA_01":  user/********@igt directory=IG_EXP_DIR LOGFILE=test_exp_stats.log estimate=STATISTICS ESTIMATE_ONLY=Y 
Estimate in progress using STATISTICS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
.  estimated "user"."SGA_W_IPN_SUBSCRIBER"     554.4 MB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  341.5 MB
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   227.5 MB
.  estimated "user"."SUBSCRIBER_USAGE_INFO"    71.95 MB
.  estimated "user"."IPN_W_PNLS"               27.16 MB
.  estimated "user"."SGA_SUBSCRIBER_COMMENTS"  27.01 MB
.  estimated "user"."DEBUG_IPN_USAGE_VALUES"   7.867 MB
.  estimated "user"."TAP_TEMP"                 7.188 MB


C. Gather DBMS_STATS for main three tables in the system
BEGIN
DBMS_STATS.unlock_table_stats('user', 'SGA_W_IPN_SUBSCRIBER');
DBMS_STATS.gather_table_stats('user', 'SGA_W_IPN_SUBSCRIBER', estimate_percent => 100);
DBMS_STATS.lock_table_stats('user', 'SGA_W_IPN_SUBSCRIBER');
END;
/

PL/SQL procedure successfully completed.

BEGIN
DBMS_STATS.unlock_table_stats('user', 'CLOVER_SUBSCRIBER_USAGE');
DBMS_STATS.gather_table_stats('user', 'CLOVER_SUBSCRIBER_USAGE', estimate_percent => 100);
DBMS_STATS.lock_table_stats('user', 'CLOVER_SUBSCRIBER_USAGE');
END;
/

PL/SQL procedure successfully completed.

BEGIN
DBMS_STATS.unlock_table_stats('user', 'IPN_SUBSCRIBER_USAGE_B');
DBMS_STATS.gather_table_stats('user', 'IPN_SUBSCRIBER_USAGE_B', estimate_percent => 50);
DBMS_STATS.lock_table_stats('user', 'IPN_SUBSCRIBER_USAGE_B');
END;

/


PL/SQL procedure successfully completed.

D. Up to date statistics, estimate=BLOCKS
;;; 
Export: Release 11.1.0.7.0 - 64bit Production on Tuesday, 23 October, 2018 19:11:42

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
;;; 
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
Starting "user"."SYS_EXPORT_SCHEMA_01":  user/********@igt directory=IG_EXP_DIR LOGFILE=test_exp_blocks_correct.log estimate=BLOCKS ESTIMATE_ONLY=Y 
Estimate in progress using BLOCKS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   2.187 GB
.  estimated "user"."SGA_SUBSCRIBER_SFI"       2.127 GB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  1.781 GB
.  estimated "user"."SGA_W_IPN_SUBSCRIBER"       608 MB
.  estimated "user"."SUBSCRIBER_USAGE_INFO"      424 MB
.  estimated "user"."TAP_TEMP"                   256 MB



E. Up to date statistics, estimate=STATISTICS 
Export: Release 11.1.0.7.0 - 64bit Production on Tuesday, 23 October, 2018 18:50:41

Copyright (c) 2003, 2007, Oracle.  All rights reserved.
;;; 
Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
Starting "user"."SYS_EXPORT_SCHEMA_01":  user/********@igt directory=IG_EXP_DIR LOGFILE=test_exp_stats_correct.log estimate=STATISTICS ESTIMATE_ONLY=Y 
Estimate in progress using STATISTICS method...
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   1.531 GB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  1.053 GB
.  estimated "user"."SGA_W_IPN_SUBSCRIBER"     448.0 MB
.  estimated "user"."SUBSCRIBER_USAGE_INFO"    71.95 MB
.  estimated "user"."IPN_W_PNLS"               27.16 MB
.  estimated "user"."SGA_SUBSCRIBER_COMMENTS"  27.01 MB
.  estimated "user"."DEBUG_IPN_USAGE_VALUES"   7.867 MB
.  estimated "user"."TAP_TEMP"                 7.188 MB


==============================
Conclusion
==============================

1. Gathering table stats has change dramatically the estimated size when using STATISTICS method.

2. STATISTICS method estimate was significantly lower than the BLOCKS estimate.


When Using Blocks Estimate:
Before statistics gathering:

.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   2.187 GB
.  estimated "user"."SGA_SUBSCRIBER_SFI"       2.127 GB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  1.781 GB

After statistics gathering:
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   2.187 GB
.  estimated "user"."SGA_SUBSCRIBER_SFI"       2.127 GB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  1.781 GB

When Using Statistics Estimate:

Before statistics gathering:

.  estimated "user"."SGA_W_IPN_SUBSCRIBER"     554.4 MB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  341.5 MB
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   227.5 MB

After statistics gathering:
.  estimated "user"."IPN_SUBSCRIBER_USAGE_B"   1.531 GB
.  estimated "user"."CLOVER_SUBSCRIBER_USAGE"  1.053 GB
.  estimated "user"."SGA_W_IPN_SUBSCRIBER"     448.0 MB


Why was STATISTICS method estimate was significantly lower than the BLOCKS estimate?
That might be due to fragmentation of the table blocks in the OLTP system.
While BLOCKS represent the actual size of the segments, the STATISTICS represent the optimal size, when segments are not fragmented.