Chinaunix首页 | 论坛 | 博客
  • 博客访问: 139578
  • 博文数量: 46
  • 博客积分: 3033
  • 博客等级: 中校
  • 技术积分: 550
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-05 16:13
文章分类

全部博文(46)

文章存档

2011年(1)

2010年(8)

2009年(22)

2008年(15)

我的朋友

分类: Oracle

2008-12-29 11:27:35

从Oracle的SGA的构成来看,它是推崇使用参数绑定的。使用参数绑定可以有效的使用Share Pool,对已经缓存的SQL不用再硬解析,能明显的提高性能。

具体实践如下:

SQL>create table test (a number(10));< 

再创建一个存储过程:

create or replace procedure p_test is
  i number(10);
begin
  i := 0;
   while i <= 100000 loop
    execute immediate ' insert into test values (' || to_char(i) || ')';
    i := i + 1;
  end loop;

  commit;

end p_test; 

先测试没有使用参数绑定的:

运行 p_test 后,用时91.111秒。

再创建一个使用参数绑定的:

create or replace procedure p_test is
  i number(10);
begin
  i := 0;
  while i <= 100000 loop
    execute immediate ' insert into test values (:a)'
      using i;
    i := i + 1;
  end loop;
  commit;

end p_test; 

运行 p_test 后,用时55.099秒。

从上面的运行时间可以看出,两者性相差 39.525%,可见,用不用参数绑定在性能上相差是比较大的。

阅读(762) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~