Pending Statistics
Starting with the 11g Release 1 (11.1), when gathering statistics, you have the option to automatically publish the statistics at the end of the gather operation (default behavior), or to have the new statistics saved as pending. Saving the new statistics as pending allows you to validate the new statistics and publish them only if they are satisfactory.
You can check whether or not the statistics will be automatically published as soon as they are gathered by checking the value of the PUBLISH
attribute using the DBMS_STATS
package:
Select dbms_stats.get_prefs('PUBLISH') publish from dual;
This query will return either TRUE
or FALSE
. TRUE
indicates that the statistics will be published as and when they are gathered, while FALSE
indicates that the statistics will be kept pending.
Note:
Published statistics are stored in data dictionary views, such asUSER_TAB_STATISTICS
and USER_IND_STATISTICS
. Pending statistics are stored in views such as USER_TAB_PENDING_STATS
and USER_IND_PENDING_STATS
.You can change the PUBLISH
setting at either the schema or the table level. For example, to change the PUBLISH
setting for the customers
table in the SH
schema, execute the statement:
Exec dbms_stats.set_table_prefs('SH', 'CUSTOMERS', 'PUBLISH', 'false');
Subsequently, when you gather statistics on the customers
table, the statistics will not be automatically published when the gather job completes. Instead, the newly gathered statistics will be stored in the USER_TAB_PENDING_STATS
table.
By default, the optimizer uses the published statistics stored in the data dictionary views. If you want the optimizer to use the newly collected pending statistics, set the initialization parameter OPTIMIZER_USE_PENDING_STATISTICS
to TRUE
(the default value is FALSE
), and run a workload against the table or schema:
alter session set optimizer_use_pending_statistics = TRUE;
The optimizer will use the pending statistics instead of the published statistics when compiling SQL statements.If the pending statistics are valid, they can be made public by executing the following statement:
Exec dbms_stats.publish_pending_stats(null, null);
You can also publish the pending statistics for a specific database object. For example, by using the following statement:
Exec dbms_stats.publish_pending_stats('SH','CUSTOMERS');
If you do not want to publish the pending statistics, delete them by executing the following statement:
Exec dbms_stats.delete_pending_stats('SH','CUSTOMERS');
You can export pending statistics using dbms_stats.export_pending_stats
function. Exporting pending statistics to a test system enables you to run a full workload against the new statistics.
http://docs.oracle.com/cd/B28359_01/server.111/b28274/stats.htm#BEIEGBGI
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
2014-11-06 oracle数据迁移到mysql
2014-11-06 centOS下安装mysql workbench详细步骤
2014-11-06 VNC Server Installation on CentOS 6.5