您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

创建索引前后执行计划的变更和软硬解析的比较

2024/2/18 8:34:31发布24次查看
我当时的回答是:有索引了,统计信息变了。走索引了,执行计划变了。 但是软硬解析是对于sql语句而言的吧?只要共享池中存在此sq
环境:oel+oracle 10.2.0.5 rac
今天在itpub上回答一个网友的提问,rt:我第一次执行了一条sql之后,这条sql通过了硬解析,得到了执行计划,当再次执行这条sql时,会进行软解析是吧,不会通过优化器得到新的执行计划。如果我增加了一条索引,通过索引执行这条sql更好,在执行这条sql是进行软解析吗?(统计信息的改变,会导致sql进行硬解析吗?)
我当时的回答是:有索引了,,统计信息变了。走索引了,执行计划变了。 但是软硬解析是对于sql语句而言的吧?只要共享池中存在此sql副本,将直接执行软解析;个人认为未经analyze表前,会被软解析
相关链接:
oracle中检查是否需要重构索引
使用倒序索引提升order by desc性能
oracle分析表和索引
oracle入门教程:把表和索引放在不同的表空间里 
答案应该是硬解析;
中午午休的时候,趴那儿回顾了一下这个案例,但是思前想后总感觉有点不对,一切以事实说话,决定起来测试一下;测试过程和结果如下:
sql> show user
user is sys
sql> drop index tt_idx;
drop index tt_idx
          *
error at line 1:
ora-01418: specified index does not exist
sql> drop table tt purge;
drop table tt purge
          *
error at line 1:
ora-00942: table or view does not exist
创建一张新表tt:
sql> create table tt as select * from dba_objects;
table created.
打开autotrace并开始第一次根据条件检索新表tt:
sql> set autotrace on; 
sql> select object_id,object_name from tt where object_id=10;
object_id      object_name 
----------      --------------------------------------
        10      c_user#
execution plan 
---------------------------------------------------------- 
plan hash value: 264906180
-------------------------------------------------------------------------- 
| id  | operation        | name | rows  | bytes | cost (%cpu)| time    | 
-------------------------------------------------------------------------- 
|  0 | select statement  |      |    8 |  632 |  156  (1)| 00:00:02 | 
|*  1 |  table access full| tt  |    8 |  632 |  156  (1)| 00:00:02 | 
--------------------------------------------------------------------------
predicate information (identified by operation id): 
---------------------------------------------------
1 - filter(object_id=10)
note 
----- 
  - dynamic sampling used for this statement
statistics 
---------------------------------------------------------- 
        68  recursive calls 
          0  db block gets 
        785  consistent gets 
        701  physical reads 
          0  redo size 
        481  bytes sent via sql*net to client 
        400  bytes received via sql*net from client 
          2  sql*net roundtrips to/from client 
          0  sorts (memory) 
          0  sorts (disk) 
          1  rows processed
sql>
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product