I just have a simple question regarding dbms_stats.gather_table_stats. In our application this statement occurs just after creating the index for the table. It is called as
.
We are using Oracle 10.2g. Now question is when will exactly the information will be gathered? Will it be gathered on every update of table, or when some criteria is satisfied? Or is it that it will be gathered only when you call gather_table_stats again? EXEC DBMS_STATS.GATHER_TABLE_STATS(< schemaname >, < tablename 开发者_JS百科>)
The stats are gathered when the package is called (and the package won't return until the gathering is complete).
Typically there is an automatic job that will gather stats where existing stats have gone 'stale'. Tables that have been selected for monitoring will have some extra data logged on inserts/deletes/updates (visible through dba_tab_modifications).
When 10% of rows have been changed, the stats are 'stale' and will be re-gathered during the next automatic job. Check DBA_JOBS to see if/when your database is configured to gather stats on stale tables (hint - avoid doing it during a heavy usage time).
In addition to Gary's good answer, the GATHER_STATS_JOB scheduled task that runs the stats on the default 10g databases is configured by default to run during two "maintenance window groups", which are WEEKEND_WINDOW and WEEKNIGHT_WINDOW. The former starts at 00:00 Saturday and runs for 48 hours, the latter starts at 10pm each weeknight and runs for 8 hours. Your stats jobs can only run during those times unless you change the schedule or the windows. Those windows may or may not be good in your environment.
精彩评论