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

Oracle存储过程本地编译方式

2024/5/3 14:39:30发布21次查看
通常将oracle存储过程编译为本地编译方式的测试记录. 测试用表: sqlgt; create table t1(rid number); table created sqlgt; c
通常将oracle存储过程编译为本地编译方式的测试记录.
测试用表:
sql> create table t1(rid number);
table created
sql> create table t_n(rid number);
table created
测试用的存储过程:
create or replace procedure pro_xcl(p1 varchar2)
is
begin
    dbms_output.put_line(p1);
insert into t1 select rownum as rr
    from dual connect by rownum     commit;
exception
  when others then
    dbms_output.put_line(sqlcode||' : '||substr(sqlerrm,200)); 
end;
测试:
sql> set serveroutput on
sql> set timing on
--查看存储过程当前编译方式
sql>  select plsql_code_type from all_plsql_object_settings where;
plsql_code_type
--------------------------------------------------------------------------------
interpreted
executed in 0.14 seconds
sql> exec pro_xcl('11g interpreted');
11g interpreted
pl/sql procedure successfully completed
executed in 4.68 seconds
更改下,pro_xcl,将t1换成t_n表。
测试本地编译方式出来的存储过程运行速度.
-- 用本地编译方式编译存储过程pro_xcl
sql> alter procedure pro_xcl compile plsql_code_type=native;
procedure altered
executed in 0.062 seconds
 --查看存储过程当前编译方式,可看到,已变成本地编译方式了
sql>  select plsql_code_type from all_plsql_object_settings where;
plsql_code_type
--------------------------------------------------------------------------------
native
executed in 0.063 seconds
sql> exec pro_xcl('11g native');
11g native
pl/sql procedure successfully completed
executed in 4.087 seconds
本地编译方式要快0.6秒,没有快到想象的夸张的地步。
设置当前session程序编译方式默认为本地编译:
alter session set plsql_code_type=native;
设置数据库默认程序为本地编译方式:
alter system set plsql_code_type=native;
与plsql编译相关一些参数:
sql> show parameter plsql
name                                type        value
------------------------------------ ----------- ------------------------------
plsql_ccflags                        string     
plsql_code_type                      string      interpreted
plsql_debug                          boolean    false
plsql_optimize_level                integer    2
plsql_v2_compatibility              boolean    false
plsql_warnings                      string      disable:all

该用户其它信息

VIP推荐

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