oracle wait event “enq: SQ – contention” and DBA_DB_LINK_SOURCES
从12c 版本开始新引入DBA_DB_LINK_SOURCES(link_sources$)记录了远程dblink 曾登录本地数据的会话信息(hostname、IP, dbname、用户名、logon_time、logon_count),在使用DBLINK的环境中有时会看到,dblink session在等待“Enq: SQ – contention ”, 这个wait event并不陌生与sequence相关,看看是否sequence调用频反cache过小,或当时的row cache出现了问题。
案例
USERNAME SID EVENT MACHINE MODULE STATUS LAST_CALL_ET SQL_ID WAI_SECINW ROW_WAIT_OBJ# SQLTEXT BS CH# OSUSER HEX ----------- ---------- -------------------- ---------- -------------------- -------- ------------ --------------- ---------- ------------- ------------------------------ ---------- ---- ---------- --------- ANBOB 7902 enq: SQ - contention anbobd1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 147 grid 17562c4 ANBOB 8104 enq: SQ - contention anbobc1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 147 grid 17562be ANBOB 8758 enq: SQ - contention anbobb1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 147 grid 17562c3 ANBOB 90 enq: SQ - contention anboba1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 148 grid 17562c0 ANBOB 11764 enq: SQ - contention anbobd1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 148 grid 17562bc ANBOB 7636 enq: SQ - contention anboba1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 148 grid 17562bd ANBOB 557 enq: SQ - contention anboba1 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 149 grid 17562c1 ANBOB 2638 enq: SQ - contention anboba2 oracle ACTIVE 4 d2217udafsm66 0:3 -1 insert into link_sources$( sou : 148 grid 17562bf
能看出是一些DBLINK会话,当时在执行的SQL
SQLid:d2217udafsm66 insert into link_sources$( source_id, username, user#, first_logon_time, last_logon_time, logon_count, db_name, dbid, host_name, ip_address, protocol, db_unique_name) VALUES (link_source_id_seq.nextval, :usrnm , :usri, SYSTIMESTAMP AT TIME ZONE 'UTC' , SYSTIMESTAMP AT TIME ZONE 'UTC', 1, :dbldbn, :dbldbi, SYS_CONTEXT('USERENV', 'HOST'), SYS_CONTEXT('USERENV', 'IP_ADDRESS'), SYS_CONTEXT('USERENV', 'NETWORK_PROTOCOL'), SUBSTR(SYS_CONTEXT('USERENV', 'DBLINK_INFO'),20, INSTR(SYS_CONTEXT('USERENV', 'DBLINK_INFO'),',',1,1)-20)) SQL> @seq LINK_SOURCE_ID_SEQ SEQUENCE_OWNER SEQUENCE_NAME MIN_VALUE MAX_VALUE INCREMENT_BY C O CACHE_SIZE LAST_NUMBER S E S K --------------------------- --------------------------- ---------- ---------- ------------ - - ---------- ----------- - - - - SYS LINK_SOURCE_ID_SEQ 1 1.0000E+28 1 N N 10 9415641 N N N N
Note:
当时在执行的在记录link_sources$系统表,是DBA_DB_LINK_SOURCES的基表,记录dblink访问记录,使用的sequence 是 LINK_SOURCE_ID_SEQ, 当前的cache值是10, 以经验来看,以后ORACLE数据库除了审计AUDIT特性调用的sys.AUDSES$ 系统序列以外,以后又多了个序列建议提前增加cache那就是 LINK_SOURCE_ID_SEQ .
通常系统中调用DBLINK这么频繁,就需要考虑应用设计是否合理?SQL执行效率中是否浪费在dblink network上, 还有是否当时library cache出现性能问题,如伴随library cache lock等待。
DBA_DB_LINK_SOURCES Bugs
DBA_DB_LINK_SOURCES的引入在一些低版本(11g)访问时12c或更新的版本时可能出现ORA-603 ORA-3106。
How to disable DBA_DB_LINK_SOURCES ?
set “_db_link_sources_tracking”=FALSE
对不起,这篇文章暂时关闭评论。