title: Gather stats on subpartitioned tables in Oracle
body: <p>There is a table that gets updated by multiple batches running in parallel. i.e., 
    -  the application runs an analysis, which has an analysis id and 
    -  this analysis inserts data into a table "ANALYSIS_TABLE" in batches and
    -  each batch has a batch id
  I need to gather statistics on this table "ANALYSIS_TABLE" when each batch is finished.</p>
  
  <p>The structure of the table is:</p>
  
  <pre>
  Analysis_id | Batch_id | Analysis_Val | Specific_key |
  ----------- |  ------  | ------------ | ------------
  A1          |    B1    |     2.0      |     A1-B1    |
  A1          |    B1    |     5.0      |     A1-B1    |
  </pre>
  
  <p>I need to call gather statistics like, 
       call pack_stats.gather_table_stats('ANALYSIS_TABLE','A1-B1') ,</p>
  
  <pre><code> call pack_stats.gather_table_stats('ANALYSIS_TABLE','A1-B2') (*if it has a 
   value for specific_key column like 'A1-B2'*)
  
   and so on.
  </code></pre>
  
  <p>But when I call this, oracle does not identify the keys 'A1-B1' , 'A1-B2' etc.</p>
  
  <p>The table 'ANALYSIS_TABLE' is a subpartitioned table.
  Executing the below query shows the subpartition_key which has no relation to the data in 'Specific_key' column :</p>
  
  <pre><code>*select table_name, partition_name,subpartition_name, last_analyzed, 
   num_rows from user_tab_statistics where table_name='ANALYSIS_TABLE' and 
   partition_name='P000000000563'*
  </code></pre>
  
  <pre>
  Table_name    | partition_name | subpartition_name   | last_analyzed | num_rows|
  --------------| -------------- | -----------------   | ------------- | -------- 
  ANALYSIS_TABLE | P000000000563 | (null)               | 04-Apr-17     |   2   |
  ANALYSIS_TABLE | P000000000563 | P000000000563_null   | 04-Apr-17     |   0   |
  ANALYSIS_TABLE | P000000000563 | P000000000563_DEFAULT| 04-Apr-17     |   2   |
  </pre>
  
  <p>How can I make sure that the values in 'specific_key' column in my first table is reflected in the subpartition_name column of user_tab_statistics ?</p>
  
  <p>or rather how to make a relation between 'specific_key' column and the subpartition_name column.</p>
  
  <p>Any other ideas on gathering statistics for each batch as I have mentioned is also welcome.</p>
  
  <p>Thanks!</p>