SQL> SQL> set lines 200 pagesize 200 SQL> select * from table(dbms_xplan.display_cursor('&sql_id', NULL, 'ALL')); Enter value for amp: 7wanaturqndn1 old 1: select * from table(dbms_xplan.display_cursor('&sql_id', NULL, 'ALL')) new 1: select * from table(dbms_xplan.display_cursor('7wanaturqndn1;sql_id', NULL, 'ALL'))
PLAN_TABLE_OUTPUT ---------------------------------------------------------------------------------------------- SQL_ID 7wanaturqndn1, child number 0 ------------------------------------- update t1_tx set name='bitmap' where id=4 Plan hash value: 1842098942 ----------------------------------------------------------------------------------- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | ----------------------------------------------------------------------------------- | 0 | UPDATE STATEMENT | | | | 1 (100)| | | 1 | UPDATE | T1_TX | | | | | |* 2 | INDEX UNIQUE SCAN| SYS_C0010951 | 1 | 25 | 1 (0)| 00:00:01 | -----------------------------------------------------------------------------------
session 1: SQL> select sid from v$mystat where rownum=1;
SID ---------- 45
SQL> select * from t1_tx;
ID NAME ---------- -------------------- 1 wang 2 wang 3 tx 4 bitmap
SQL> update t1_tx set name='enmotech' where id=2;
1 row updated.
SQL> commit;
Commit complete.
SQL>
session 2: SQL> select sid from v$mystat where rownum=1;
SID ---------- 74
SQL> update t1_tx set name='xyz'where id=4;
1 row updated.
SQL> commit;
Commit complete.
SQL>
即使我分別開2個會話執行100w次,也不會出現tx鎖 session 1: SQL> declare 2 c number; 3 begin 4 for i in 1 .. 1000000 loop 5 update t1_tx set name = 'shit1' where id = 2; 6 end loop; 7 end; 8 /
PL/SQL procedure successfully completed.
SQL>
session 2: SQL> declare c number; 2 begin 3 for i in 1 .. 1000000 loop 4 update t1_tx set name = 't-shit' where id = 3; 5 end loop; 6 end; 7 / PL/SQL procedure successfully completed.
SQL>
session 3: SQL> set lines 200 pages 999 SQL> col event for a60 SQL> select inst_id,event,count(*) from gv$session where status='ACTIVE' and (wait_class<>'Idle' or event not like 'SQL*Net%') group by inst_id,event order by 1,3;