sequence cash size i not that important s
Alex S, September 21, 2018 - 5:45 am UTC
Try this test to find the optimal sequence cache size.
I would not expect 50000 fits all hats.
create or replace
procedure test_sequence_cache(
p_cache_size integer := 0
, p_init_ind integer := 10000000
, p_ins_rows integer := 10000
, p_repeat integer := 10
)
is
l_begin_ts timestamp(6);
l_run_time varchar2(30);
l_nextval integer;
begin
execute immediate 'truncate table t reuse storage';
execute immediate 'alter sequence t_seq cycle minvalue 100000 '
|| case when p_cache_size = 0 then 'nocache' else 'cache '||to_char(p_cache_size) end;
l_begin_ts := current_timestamp;
for x in 1 .. p_repeat loop
for r in (
select 1 from b_posting
where id between p_init_ind + 1 and p_init_ind + p_ins_rows
) loop
select t_seq.nextval into l_nextval from dual;
end loop;
end loop;
l_run_time := to_char(lib.ts_dif(l_begin_ts, current_timestamp)/p_repeat,'999.9999');
dbms_output.put_line('Cache size: '||to_char(p_cache_size, '999990')||' -> Avg run time: '|| l_run_time);
end;
/
begin
test_sequence_cache(0, p_repeat => 20);
test_sequence_cache(20, p_repeat => 20);
test_sequence_cache(50, p_repeat => 20);
test_sequence_cache(100, p_repeat => 20);
test_sequence_cache(200, p_repeat => 20);
test_sequence_cache(250, p_repeat => 20);
test_sequence_cache(500, p_repeat => 20);
test_sequence_cache(1000, p_repeat => 20);
test_sequence_cache(2000, p_repeat => 20);
test_sequence_cache(5000, p_repeat => 20);
test_sequence_cache(10000, p_repeat => 20);
end;
/
begin
test_sequence_cache(0, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(20, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(50, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(100, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(200, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(250, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(500, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(1000, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(2000, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(5000, p_ins_rows => 100000, p_repeat => 10);
test_sequence_cache(10000, p_ins_rows => 100000, p_repeat => 10);
end;
/
September 26, 2018 - 12:40 am UTC
nice input