eygle.com   eygle.com
eygle.com  
 

« 当医生要你吃不该吃的药 | Digest首页 | E.F.codd全关系系统的十二条基本准则 »

关于 cursor_sharing = similar

链接:

作者:biti_rainy (出处

我们先看看在表没有分析无统计数据情况下的表现

SQL> alter session set cursor_sharing = similar; Session altered.

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4948
parse time elapsed 4468
parse count (total) 170148
parse count (hard) 1619 (硬分析次数)
parse count (failures) 80

SQL> select count(*) from t where object_id = 1000;

COUNT(*)
----------
0

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4948
parse time elapsed 4468
parse count (total) 170172
parse count (hard) 1620
parse count (failures) 80

SQL> /

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4948
parse time elapsed 4468
parse count (total) 170176
parse count (hard) 1620
parse count (failures) 80

SQL> select count(*) from t where object_id = 1000;

COUNT(*)
----------
0

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4948
parse time elapsed 4468
parse count (total) 170178
parse count (hard) 1620
parse count (failures) 80

SQL> select count(*) from t where object_id = 1001;

COUNT(*)
----------
0

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4948
parse time elapsed 4468
parse count (total) 170180
parse count (hard) 1620(即使object_id发生变化依然没有硬解析)
parse count (failures) 80

我们再来看分析表和字段信息后的表现

SQL> analyze table t1 compute statistics for table for columns object_id;

Table analyzed.

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4973
parse time elapsed 4495
parse count (total) 170982
parse count (hard) 1640
parse count (failures) 80

SQL> select count(*) from t1 where object_id = 5000;

COUNT(*)
----------
0

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4973
parse time elapsed 4495
parse count (total) 170984
parse count (hard) 1641
parse count (failures) 80

SQL> select count(*) from t1 where object_id = 5000;

COUNT(*)
----------
0

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4973
parse time elapsed 4495
parse count (total) 171008
parse count (hard) 1641 (重复执行没发生变化)
parse count (failures) 80

SQL> select count(*) from t1 where object_id = 5001;

COUNT(*)
----------
0

SQL> select name,value from v$sysstat where name like '%parse%';

NAME VALUE
---------------------------------------------------------------- ----------
parse time cpu 4973
parse time elapsed 4495
parse count (total) 171010
parse count (hard) 1642 (当object_id变化的时候产生硬分析)
parse count (failures) 80

SQL> select sql_text,child_number from v$sql where sql_text like 'select count(*) from t1 where%';

SQL_TEXT
--------------------------------------------------------------------------------
CHILD_NUMBER
------------
select count(*) from t1 where object_id = :"SYS_B_0"
0

select count(*) from t1 where object_id = :"SYS_B_0"
1

可以看出若存在object_id的 histograms ,则每次是不同的 值 的时候都产生硬解析 ,若不存在 histograms ,则不产生硬解析 。换句话说,当表的字段被分析过存在histograms的时候,similar 的表现和exact一样,当表的字段没被分析不存在histograms的时候,similar的表现和force一样。这样避免了一味地如force一样转换成变量形式,因为有hostograms的情况下转换成变量之后就容易产生错误的执行计划,没有利用上统计信息。而exact呢,在没有hostograms的情况下也要分别产生硬解析,这样的话,由于执行计划不会受到数据分布的影响(因为没有统计信息)重新解析是没有实质意义的。而similar则综合了两者的优点。

By eygle on 2007-09-05 15:39 | Comments (1) | Posted to Oracle摘 |Pageviews:

相关文章 随机文章
  • Oracle Export Parameters-Buffer
  • O7_DICTIONARY_ACCESSIBILITY
  • global cache cr request等待
  • 甲骨文在2008财年第二季度客户迅猛增长
  • Configure the hangcheck-timer Kernel Module
  • 负利率、人民币升值以及通货膨胀
    北京公交空调车明年一元起价
    DS8000,DMX3,HDS USP究竟哪个性能会表现的好些?
    SQL Server发展史知识介绍
    美军地面部队:101空降师
    网上相关主题:
    Google

    留言 (1)

    SQL> analyze table t1 compute statistics for table for columns object_id;

    Table analyzed.

    这个是不是写错了?应该是analyze table t compute statistics for table for columns object_id吧?

    另外,这个实验对数据库的版本有没有要求?对于10g,实验结果是否一样?

    Posted by: chenfeng at September 24, 2007 10:25 AM

    发表留言:



    Remember Me?
    (输入验证码后方可评论,谢谢支持)



    CopyRight © 2004 eygle.com, All rights reserved.