Oracle分析表和索引(analyze)

分析表

analyze table tablename compute statistics;

分析索引

analyze index indexname compute statistics;

该语句生成的统计信息会更新user_tables这个视图的统计信息,分析的结果被Oracle用于基于成本的优化生成更好的查询计划

对于使用CBO(Cost-Base Optimization)很有好处,可以使用更可靠的table信息,从而执行计划也可以更准确一些,在10g会自动analyze,之前的版本需要手动定期

analyze table 一般可以指定分析: 表,所有字段,所有索引字段,所有索引。 若不指定则全部都分析。

sql 复制代码
SQL> analyze table my_table compute statistics;  

SQL> analyze table my_table compute statistics for table for all indexes for all columns;   

SQL> analyze table my_table compute statistics for table for all indexes for all indexed columns;

其中:

SQL> analyze table my_table compute statistics;  

等价于:

SQL> analyze table my_table compute statistics for table for all indexes for all columns;

sample:

sql 复制代码
analyze table t1 compute statistics for table;
analyze table t2 compute statistics for all columns;
analyze table t3 compute statistics for all indexed columns;

analyze table t5 compute statistics for all indexes; 

analyze table t4 compute statistics;     (不指定)

另外,可以删除分析数据:

sql 复制代码
SQL> analyze table my_table delete statistics;

SQL> analyze table my_table delete statistics for table for all indexes for all indexed columns;
相关推荐
执笔诉情殇〆3 分钟前
springboot集成达梦数据库,取消MySQL数据库,解决问题和冲突
数据库·spring boot·mysql·达梦
软件技术NINI41 分钟前
springMvc的简单使用:要求在浏览器发起请求,由springMVC接受请求并响应,将个人简历信息展示到浏览器
数据库·mysql
SailingCoder2 小时前
MongoDB Memory Server与完整的MongoDB的主要区别
数据库·mongodb
水木石画室2 小时前
MongoDB 常用增删改查方法及示例
数据库·mongodb
旷世奇才李先生2 小时前
MongoDB 安装使用教程
数据库·mongodb
qq_339282232 小时前
mongodb 中dbs 时,local代表的是什么
数据库·mongodb
阿里云大数据AI技术3 小时前
AI搜索 MCP最佳实践
数据库·人工智能·搜索引擎
笑衬人心。3 小时前
项目中数据库表设计规范与实践(含案例)
服务器·数据库·设计规范
cpsvps3 小时前
触发器设计美国VPS:优化数据库性能的关键策略
数据库·oracle
s153353 小时前
数据结构之顺序表,链表,栈,队列
数据结构·数据库