Do I need to run gather_table_stats every time I create an index so that the Oracle optimizer can use it?

I have seen some examples of creating indexes. After that, the following was done:

exec dbms_stats.gather_table_stats(...)

Does Oracle need to pay attention to the index? I think that statistics are collected every night (?), But there were situations when I created the index, I was disappointed with the explanation plans that followed. Maybe I'm missing a step?

+3
source share
2 answers

It depends on the version of Oracle.

In versions prior to 9i, you had to explicitly collect statistics after creating the index before the optimizer with a realistic chance of using it.

9i Oracle COMPUTE STATISTICS CREATE INDEX. . COMPUTE STATISTICS, , CBO, , .

10g , Oracle , , COMPUTE STATISTICS. - - , , GATHER_INDEX_STATS , .

10g , , , , . DCookie 10g. Oracle 11g, - .

+8

GATHER_STATS_JOB. MAINTENANCE_WINDOW_GROUP. , , , , .. - gather_table_stats .

+4

Source: https://habr.com/ru/post/1774396/


All Articles