- 最后登录
- 2014-6-20
- 在线时间
- 91 小时
- 威望
- 0
- 金钱
- 352
- 注册时间
- 2013-5-20
- 阅读权限
- 10
- 帖子
- 34
- 精华
- 0
- 积分
- 0
- UID
- 1100
|
1#
发表于 2013-8-9 11:13:27
|
查看: 4256 |
回复: 9
- SQL> select * from v$version;
- BANNER
- --------------------------------------------------------------------------------
- Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
- PL/SQL Release 11.2.0.1.0 - Production
- CORE 11.2.0.1.0 Production
- TNS for Linux: Version 11.2.0.1.0 - Production
- NLSRTL Version 11.2.0.1.0 - Production
复制代码 软解析也会消耗CPU的资源,最理想的情况就是一次解析,多次执行
执行sql语句- SQL> select count(*) from t;
- COUNT(*)
- ----------
- 0
- SQL> Select Hash_Value, Sql_Text, Parse_Calls, Executions From V$sql Where sql_text='select count(*) from t';
- HASH_VALUE SQL_TEXT PARSE_CALLS EXECUTIONS
- ---------- ---------------------------------------- ----------- ----------
- 2763161912 select count(*) from t 1 1
复制代码 解析和执行都是一次,当再次执行的时候- SQL> select count(*) from t;
- COUNT(*)
- ----------
- 0
- SQL> Select Hash_Value, Sql_Text, Parse_Calls, Executions From V$sql Where sql_text='select count(*) from t';
- HASH_VALUE SQL_TEXT PARSE_CALLS EXECUTIONS
- ---------- ---------------------------------------- ----------- ----------
- 2763161912 select count(*) from t 2 2
复制代码 解析和执行都加了1,为什么解析数会加1?这里应该是可以直接使用刚才解析过的sql语句啊?
当我用一个pl/sql块去跑的时候,结果又不一样了- SQL> begin
- 2 for i in 1..10000 loop
- 3 execute immediate 'select count(*) from t';
- 4 end loop;
- 5 end;
- 6 /
- PL/SQL procedure successfully completed.
- SQL> Select Hash_Value, Sql_Text, Parse_Calls, Executions From V$sql Where sql_text='select count(*) from t';
- HASH_VALUE SQL_TEXT PARSE_CALLS EXECUTIONS
- ---------- ---------------------------------------- ----------- ----------
- 2763161912 select count(*) from t 2 2
- 2763161912 select count(*) from t 1 10000
复制代码 这次确实是一次解析,多次执行!
请各位老师出来指导一下啊,确实没明白!
|
|