简体   繁体   中英

Import/Export/Copy table/(sub)partition statistics in oracle

I have some oracle tables with partitions (and suppartions). My aim is, whenever I create a new partition to copy all the statistics from the latest partition to the new one.

I have found the following ways to do that

  • dbms_stats.copy_table_stats
  • dbms_stats.get_table_stats and then dbms_stats.set_table_stats
  • dbms_stats.export_table_stats and then dbms_stats.import_table_stats

However, I could not find the difference between those methods.

As I understand copy_table_stats is the newest addition and if I am not mistaken it is available after 10.2.0.4 version. The get/set and export/import methods need some stats manipulation in order to work (eg Update C2 in stats table).

Am I correct? I have not found somewhere documented, how each one method handles the suppartitions, for example for copy_table_stats I need to copy also the subpartition statistics after copping the partition statistics. Is this also true for the other methods?

In general is there any significant difference between those 3 methods? What should I consider? Is it documented somewhere?

You may want to use get/set (and probably dbms_stats.convert_raw_value) if you want to re-set and modify some stat values.

export/import is useful when the goal is to release (apply) stats on another instance or drop table, re-create it and copy (some) stats afterwards. You need auxiliary table to preserve stats in this case.

copy stats is ideal and typical way to achieve your goal.

Update

To find quick explanation just type keywords and "white paper" in google

(I found below links using white paper dbms_stats copy_stats )

Understanding Optimizer Statistics

and with all the latest changes

Understanding Optimizer Statistics With Oracle Database 12c Release 2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM