简体   繁体   English

有关dbms_stats.gather_table_stats的问题

[英]Question regarding dbms_stats.gather_table_stats

I just have a simple question regarding dbms_stats.gather_table_stats. 我只是对dbms_stats.gather_table_stats有一个简单的问题。 In our application this statement occurs just after creating the index for the table. 在我们的应用程序中,此语句仅在为表创建索引之后发生。 It is called as 被称为

 EXEC DBMS_STATS.GATHER_TABLE_STATS(< schemaname >, < tablename >)
. We are using Oracle 10.2g. 我们正在使用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? 还是仅当您再次调用collect_table_stats时才会收集?

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). 选择进行监视的表将在插入/删除/更新中记录一些额外的数据(可通过dba_tab_modifications看到)。

When 10% of rows have been changed, the stats are 'stale' and will be re-gathered during the next automatic job. 当更改了10%的行时,统计信息将“过时”,并且将在下一个自动作业期间重新收集。 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). 检查DBA_JOBS以查看是否/何时将数据库配置为在过时的表上收集统计信息(提示-避免在使用时间过长的情况下这样做)。

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. 除了Gary的好答案之外,默认情况下,将在默认的10g数据库上运行统计信息的GATHER_STATS_JOB计划任务配置为在两个“维护窗口组”(即WEEKEND_WINDOW和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. 前者在星期六的00:00开始运行48小时,后者在每个工作日的晚上10点开始运行8小时。 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. 这些窗口在您的环境中可能不错,也可能不好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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