执行计划
时间:2011-09-14
来源:互联网
create table m_objects as select * from dba_objects;
create index ob_status on m_objects (status);
update m_objects u set u.status='INVALID' WHERE ROWNUM<2
select status,count(*),count(*)*100/(select count(*) from m_objects) from m_objects group by status
STATUS COUNT(*) COUNT(*)*100/(SELECTCOUNT(*)FR
1 INVALID 20 0.0401630620318493
2 VALID 49777 99.9598369379682
analyze index ob_status compute statistics
analyze table m_objects compute statistics
Issue:
select object_name, owner from mao.m_objects o where status='INVALID'
Plan hash value: 1579104485
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 24899 | 851K| 159 (3)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| M_OBJECTS | 24899 | 851K| 159 (3)| 00:00:02 |
-------------------------------------------------------------------------------
1 Why it is choosing the way of table full scan?
2 How I can do to make the sql choose the way of index scan without hint?
SQL> show parameter opti
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
filesystemio_options string
object_cache_optimal_size integer 102400
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 90
optimizer_index_cost_adj integer 80
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
plsql_optimize_level integer 2
[ 本帖最后由 luxueqin521 于 2011-9-14 13:55 编辑 ]
create index ob_status on m_objects (status);
update m_objects u set u.status='INVALID' WHERE ROWNUM<2
select status,count(*),count(*)*100/(select count(*) from m_objects) from m_objects group by status
STATUS COUNT(*) COUNT(*)*100/(SELECTCOUNT(*)FR
1 INVALID 20 0.0401630620318493
2 VALID 49777 99.9598369379682
analyze index ob_status compute statistics
analyze table m_objects compute statistics
Issue:
select object_name, owner from mao.m_objects o where status='INVALID'
Plan hash value: 1579104485
-------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
-------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 24899 | 851K| 159 (3)| 00:00:02 |
|* 1 | TABLE ACCESS FULL| M_OBJECTS | 24899 | 851K| 159 (3)| 00:00:02 |
-------------------------------------------------------------------------------
1 Why it is choosing the way of table full scan?
2 How I can do to make the sql choose the way of index scan without hint?
SQL> show parameter opti
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
filesystemio_options string
object_cache_optimal_size integer 102400
optimizer_dynamic_sampling integer 2
optimizer_features_enable string 10.2.0.1
optimizer_index_caching integer 90
optimizer_index_cost_adj integer 80
optimizer_mode string ALL_ROWS
optimizer_secure_view_merging boolean TRUE
plsql_optimize_level integer 2
[ 本帖最后由 luxueqin521 于 2011-9-14 13:55 编辑 ]
作者: luxueqin521 发布时间: 2011-09-14
统计信息不正确.
它估计有2w多行所以认为 full scan更好.
推荐用 dbms_stats.gather_table_stats 再次收集统计信息.
[ 本帖最后由 emaildba 于 2011-9-14 21:47 编辑 ]
它估计有2w多行所以认为 full scan更好.
推荐用 dbms_stats.gather_table_stats 再次收集统计信息.
[ 本帖最后由 emaildba 于 2011-9-14 21:47 编辑 ]
作者: emaildba 发布时间: 2011-09-14
yes, Thanks.

作者: luxueqin521 发布时间: 2011-09-14
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28