Oracle Sequence Nocache
預設情況下,建立Sequence時,緩衝(cache)是20.意即:20次.nextval才會觸發一次對sys.seq$的更新(update)操作。這樣就能提高SQL執行效能。
當使用者指定nocache時,如:
create sequence test_seq nocache;
每一次test_seq.nextval都會觸發一次sys.seq$更新(update)。
我們可以比較下cache 20 和nocache的效能:
create sequence test_seq1 nocache;
create sequence test_seq2 cache 20;
create table tt1 (id number);
create table tt2 (id number);
declare
v_start_time number :=dbms_utility.get_cpu_time;
v_time1 number;
begin
insert into tt1 select test_seq1.nextval from dual connect by level <= 100000;
v_time1 := dbms_utility.get_cpu_time;
dbms_output.put_line('Nocache sequence: ' || (v_time1 - v_start_time) / 100 || ' seconds');
insert into tt2 select test_seq2.nextval from dual connect by level <= 100000;
dbms_output.put_line('Caceh 20 sequence: ' || (dbms_utility.get_cpu_time - v_time1) / 100 || ' seconds');
end;
anonymous block completed
Nocache sequence: 28.37 seconds
Caceh 20 sequence: 1.83 seconds
效能差異還是相當明顯的。
當使用者指定nocache時,如:
create sequence test_seq nocache;
每一次test_seq.nextval都會觸發一次sys.seq$更新(update)。
我們可以比較下cache 20 和nocache的效能:
create sequence test_seq1 nocache;
create sequence test_seq2 cache 20;
create table tt1 (id number);
create table tt2 (id number);
declare
v_start_time number :=dbms_utility.get_cpu_time;
v_time1 number;
begin
insert into tt1 select test_seq1.nextval from dual connect by level <= 100000;
v_time1 := dbms_utility.get_cpu_time;
dbms_output.put_line('Nocache sequence: ' || (v_time1 - v_start_time) / 100 || ' seconds');
insert into tt2 select test_seq2.nextval from dual connect by level <= 100000;
dbms_output.put_line('Caceh 20 sequence: ' || (dbms_utility.get_cpu_time - v_time1) / 100 || ' seconds');
end;
anonymous block completed
Nocache sequence: 28.37 seconds
Caceh 20 sequence: 1.83 seconds
效能差異還是相當明顯的。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/638844/viewspace-1062022/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20211025]12c sequence nocache測試補充.txt
- ORACLE SEQUENCE用法Oracle
- oracle的scn及sequenceOracle
- [20220321]探究oracle sequence.txtOracle
- 不同於Oracle:SEQUENCE的區別Oracle
- [20220322]探究oracle sequence 2.txtOracle
- [20241107]nocache的編譯.txt編譯
- Oracle中Nextval用法SEQUENCE與SYS_GUID()OracleGUI
- sequence to sequence模型模型
- [20190530]ORACLE 18c - ALTER SEQUENCE RESTART.txtOracleREST
- 在Hibernate中關於Oracle sequence的使用KHOracle
- Sequence recognition
- uvm的sequence
- PostgreSQL 序列(Sequence)SQL
- python sequence序列Python
- Rainbow Bracket SequenceAIRacket
- Increasing Sequence with Fixed OR
- PostgreSQL sequence (一)SQL
- 論文閱讀:Sequence to sequence learning for joint extraction of entities and relations
- FSM:Sequence 1101 recognizer
- F - Two Sequence Queries
- 裁剪序列Cut the Sequence
- DeepLearning – Overview of Sequence modelView
- E. Block SequenceBloC
- mysql實現sequenceMySql
- LeetCode 444 sequence reconstructionLeetCodeStruct
- [LeetCode]60. Permutation SequenceLeetCode
- HDU 1711 Number Sequence(KMP)KMP
- A Proof of Golden Section of Fibonacci SequenceGo
- [AGC031D]A Sequence of PermutationsGC
- 演算法題 - Pop Sequence演算法
- HDU 6047 Maximum Sequence (貪心)
- Least Cost Bracket Sequence(貪心)ASTRacket
- 從SEQUENCE跳號說起
- [ABC234G] Divide a SequenceIDE
- abc134E - Sequence Decomposing
- Keras版Sequence2Sequence對對聯實戰——自然語言處理技術Keras自然語言處理
- HDU 6299-Balanced Sequence(貪心)
- Leetcode 298 Binary Tree Longest Consecutive SequenceLeetCode