Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Dbms_stats.gather_table_stats - how to use it more efficiently

BEDEAug 18 2017 — edited Aug 29 2017

So, when calling dbms_stats.gather table stats, there is the parameter  method_opt, which may be: "FOR ALL COLUMNS" or "FOR ALL INDEXED COLUMNS".

If I set mehod_opt=>"FOR ALL INDEXED COLUMNS", that will help the optimizer decide when to use an index and when not to use it.

The question is why should I have statistics for all columns, even those that are not indexed. Could statistics for a column that is not indexed be a really useful? I understand that having statistics on some column could show whether an index on that column helps certain queries or not. But, if I do not have any index on a column and I am positive I will not build one on that column (more indexes meaning difficulties in OLTP), then how could statistics on that column help? I say this considering that computing statistics takes quite some resources.

Then, one more aspect I think of. Having a table partitioned by range date, and knowing that the older data doesn't change, does it make any sense computing statistics for the whole table, and not only for the latest partitions, which I know have changed. Moreover, consider I do not have global indexes, but only local indexes.

Looking forward to receive advice from the more experienced and stories about use-cases.

This post has been answered by Mustafa KALAYCI on Aug 18 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 15 2017
Added on Aug 18 2017
3 comments
828 views