Q:

Dbms_Stats.Gather_Table_Stats after partition exchange in Oracle procedure?

I have an oracle procedure that inserts all the rows from "table1 Partition (P1)" into table2.  I update a field in table2 and then swap the partition back to table1:
Alter Table table1 Exchange Partition P1 WITH TABLE table2 Including Indexes Without Validation;

This works.  
Question: Do I need to gather table stats after? Code:
EXECUTE  Dbms_Stats.Gather_Table_Stats (Ownname => 'MySchema', Tabname => 'Table1', Partname 
=> 'P1, Granularity =>  'ALL', Degree => 32);

Takes a long time to run and there are some other issues involved.  
thanks a lot, I've googled and can't find a definitive answer

Steve 

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

A:

When you run exchange partition the statistics of the table will become the statistics of the partition and the statistics of the partition will become the statistics of the table, i.e. the statistics are exchanged too.
Here I have a table with three partitions and originally all statistics are there:
0:admspm@spmdtz> printStats -p location -- (*)

Table_Name|object_Type   |subobject  |last_Analyzed|num_Rows|sample_Size|
-------------------------------------------------------------------------
LOCATION  |Table         |           |06.04. 15:23 |     817|        817|
LOCATION  |TablePartition|PARTITION_1|06.04. 15:23 |     272|        272|
LOCATION  |TablePartition|PARTITION_2|06.04. 15:23 |     272|        272|
LOCATION  |TablePartition|PARTITION_3|06.04. 15:23 |     273|        273|

Now a swap out a partition and swap it back in:
0:admspm@spmdtz> create table xxx as select * from location where par_id=3;
Table Xxx created.
0:admspm@spmdtz> alter table location exchange partition partition_3 
                 with table xxx;
Table Location altered.

and the statistics are gone:
0:admspm@spmdtz> printStats -p location

Table_Name|object_Type   |subobject  |last_Analyzed|num_Rows|sample_Size|
-------------------------------------------------------------------------
LOCATION  |Table         |           |06.04. 15:23 |     817|        817|
LOCATION  |TablePartition|PARTITION_1|06.04. 15:23 |     272|        272|
LOCATION  |TablePartition|PARTITION_2|06.04. 15:23 |     272|        272|
LOCATION  |TablePartition|PARTITION_3|             |        |           |

However when I analyze the swap table 'XXX'
0:admspm@spmdtz> stats -gT xxx -- (*)

And swap back in, I get correct statistics again
0:admspm@spmdtz> alter table location exchange partition partition_3 
                 with table xxx;
Table Location altered.
0:admspm@spmdtz> printStats -p location

Table_Name|object_Type   |subobject  |last_Analyzed|num_Rows|sample_Size|
-------------------------------------------------------------------------
LOCATION  |Table         |           |06.04. 15:23 |     817|        817|
LOCATION  |TablePartition|PARTITION_1|06.04. 15:23 |     272|        272|
LOCATION  |TablePartition|PARTITION_2|06.04. 15:23 |     272|        272|
LOCATION  |TablePartition|PARTITION_3|02.10. 18:24 |     273|        273|

(*) these commands are made available by the senora tool

