oracle 列 guid plsql,using sys_guid() as primary key

Hi Andrew,

thank you very much, I remove append and I made my tests again:

sequence:-- SEQUENCE MULTI SESSION TESTdrop table t_seq;drop table tmp1;drop table tmp2;drop table tmp3;drop table tmp4;create table tmp1 cache as select 1 dummy from dual connect by level < 1000000;create table tmp2 cache as select 1 dummy from tmp1;create table tmp3 cache as select 1 dummy from tmp1; create table tmp4 cache as select 1 dummy from tmp1;drop sequence seq1 ;  create sequence seq1 start with 100000000 ; -- default 20 cache    create table t_seq      ( id     number(9) primary key      , filler varchar2(1000)      );  alter system switch logfile;alter system checkpoint;alter system flush buffer_cache;select /*+ full(tmp1) */ count(*) from tmp1; -- to make sure table is in buffer_cacheselect /*+ full(tmp2) */ count(*) from tmp2; -- to make sure table is in buffer_cacheselect /*+ full(tmp3) */ count(*) from tmp3; -- to make sure table is in buffer_cacheselect /*+ full(tmp4) */ count(*) from tmp4; -- to make sure table is in buffer_cachedrop table tmp_log;create table tmp_log(mydata varchar2(4000), optime timestamp);create or replace PROCEDURE    sp_log(p varchar2) as  PRAGMA AUTONOMOUS_TRANSACTION;begin  insert into tmp_log values (p , systimestamp);  commit;end;/create or replace procedure sp_test_seq(p number) asbegin  sp_log('START ' || p);    if p = 1 then    insert  into t_seq        select seq1.nextval ,'sdfsf' from tmp1;     elsif p = 2 then    insert into t_seq        select seq1.nextval ,'sdfsf' from tmp2;     elsif p = 3 then    insert  into t_seq        select seq1.nextval ,'sdfsf' from tmp3;     elsif p = 4 then    insert into t_seq        select seq1.nextval ,'sdfsf' from tmp4;     end if;  commit;     sp_log('END ' || p);end;/declare  x_time date := sysdate + 1/1440;begin  dbms_scheduler.create_job(job_name => 'TEST_SEQ1',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_seq(1); end;',                            enabled=> true,                            start_date=> x_time                          );  dbms_scheduler.create_job(job_name => 'TEST_SEQ2',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_seq(2); end;',                            enabled=> true,                            start_date=> x_time                          );  dbms_scheduler.create_job(job_name => 'TEST_SEQ3',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_seq(3); end;',                            enabled=> true,                            start_date=> x_time                          );  dbms_scheduler.create_job(job_name => 'TEST_SEQ4',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_seq(4); end;',                            enabled=> true,                            start_date=> x_time                          );end;/select * from user_scheduler_jobs where job_name like 'TEST%';select * from tmp_log order by optime ;START 2 26/11/2016 09.03.46.051495000 AMSTART 4 26/11/2016 09.03.46.061503000 AMSTART 3 26/11/2016 09.03.46.063793000 AMSTART 1 26/11/2016 09.03.46.065353000 AMEND 3  26/11/2016 09.06.44.423445000 AMEND 1  26/11/2016 09.06.44.425813000 AMEND 2  26/11/2016 09.06.44.587602000 AMEND 4  26/11/2016 09.06.44.589351000 AM

so the shortest one: 178 seconds  and the longest one is same 178 seconds. there were too many concurrency  event at the sessions.

sys_guid:-- SYS_GUID MULTI SESSION TESTdrop table t_raw;drop table tmp1;drop table tmp2;drop table tmp3;drop table tmp4;create table tmp1 cache as select 1 dummy from dual connect by level < 1000000;create table tmp2 cache as select 1 dummy from tmp1;create table tmp3 cache as select 1 dummy from tmp1; create table tmp4 cache as select 1 dummy from tmp1;create table t_raw      ( id     raw(16) primary key      , filler varchar2(1000)      );alter system switch logfile;alter system checkpoint;alter system flush buffer_cache;select /*+ full(tmp1) */ count(*) from tmp1; -- to make sure table is in buffer_cacheselect /*+ full(tmp2) */ count(*) from tmp2; -- to make sure table is in buffer_cacheselect /*+ full(tmp3) */ count(*) from tmp3; -- to make sure table is in buffer_cacheselect /*+ full(tmp4) */ count(*) from tmp4; -- to make sure table is in buffer_cachedrop table tmp_log;create table tmp_log(mydata varchar2(4000), optime timestamp);create or replace PROCEDURE    sp_log(p varchar2) as  PRAGMA AUTONOMOUS_TRANSACTION;begin  insert into tmp_log values (p , systimestamp);  commit;end;/create or replace procedure sp_test_guid(p number) asbegin  sp_log('START ' || p);    if p = 1 then    insert  into t_raw        select sys_guid() ,'sdfsf' from tmp1;     elsif p = 2 then    insert  into t_raw        select sys_guid() ,'sdfsf' from tmp2;     elsif p = 3 then    insert  into t_raw        select sys_guid() ,'sdfsf' from tmp3;     elsif p = 4 then    insert into t_raw        select sys_guid() ,'sdfsf' from tmp4;     end if;  commit;     sp_log('END ' || p);end;/declare  x_time date := sysdate + 1/1440;begin  dbms_scheduler.create_job(job_name => 'TEST_GUID1',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_guid(1); end;',                            enabled=> true,                            start_date=> x_time                          );  dbms_scheduler.create_job(job_name => 'TEST_GUID2',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_guid(2); end;',                            enabled=> true,                            start_date=> x_time                          );  dbms_scheduler.create_job(job_name => 'TEST_GUID3',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_guid(3); end;',                            enabled=> true,                            start_date=> x_time                          );  dbms_scheduler.create_job(job_name => 'TEST_GUID4',                            job_type => 'PLSQL_BLOCK',                            job_action => 'begin sp_test_guid(4); end;',                            enabled=> true,                            start_date=> x_time                          );end;/select * from user_scheduler_jobs where job_name like 'TEST%';select * from tmp_log order by optime ;START 4 26/11/2016 09.09.27.068091000 AMSTART 2 26/11/2016 09.09.27.118555000 AMSTART 1 26/11/2016 09.09.27.834022000 AMSTART 3 26/11/2016 09.09.27.838218000 AMEND 3  26/11/2016 09.09.31.322627000 AMEND 2  26/11/2016 09.09.32.905619000 AMEND 4  26/11/2016 09.09.32.939839000 AMEND 1  26/11/2016 09.09.33.647524000 AM

the shortest one: 3.5 seconds, the longest one: 5.8 seconds.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值