Oracle DML(非select) 操作不commit 對select的影響
註釋:
DML(非select)操作不commit,其他會話操作(update/delete)相同行/整表 產生鎖等待(enq: TX - row lock contention)
那您是否知道事物不提交對select 的影響呢?...
*************************** SESSION 1 ********************************
SQL> create table lottery as select * from dba_objects;
Table created.
SQL> select count(1) from lottery ;
COUNT(1)
----------
93291
SQL> insert into lottery select * from lottery ;
93291 rows created.
SQL> /
186582 rows created.
SQL> select count(1) from lottery ;
COUNT(1)
----------
373164
SQL> commit;
Commit complete.
SQL> delete from lottery ;
373164 rows deleted.
SQL> ...... 不提交
*************************** SESSION 2 ********************************
SQL> select count(1) from lottery ;
COUNT(1)
----------
373164
Elapsed: 00:00:06.60
Execution Plan
----------------------------------------------------------
Plan hash value: 201422644
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 1448 (1)| 00:00:18 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| lottery | 365K| 1448 (1)| 00:00:18 |
--------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
344240 consistent gets
0 physical reads
301184 redo size
424 bytes sent via SQL*Net to client
420 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
344240 consistent gets
0 physical reads
301184 redo size
424 bytes sent via SQL*Net to client
420 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
*************************** SESSION 1 ********************************
SQL> commit;
Commit complete.
SQL>
*************************** SESSION 2 ********************************
SQL> select count(1) from lottery ;
COUNT(1)
----------
0
Elapsed: 00:00:00.04
Execution Plan
----------------------------------------------------------
Plan hash value: 201422644
--------------------------------------------------------------------
| Id | Operation | Name | Rows | Cost (%CPU)| Time |
--------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 1446 (1)| 00:00:18 |
| 1 | SORT AGGREGATE | | 1 | | |
| 2 | TABLE ACCESS FULL| lottery | 1 | 1446 (1)| 00:00:18 |
--------------------------------------------------------------------
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
5335 consistent gets
0 physical reads
0 redo size
421 bytes sent via SQL*Net to client
420 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
0 recursive calls
0 db block gets
5335 consistent gets
0 physical reads
0 redo size
421 bytes sent via SQL*Net to client
420 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
1 rows processed
SQL>
總結:
Oracle DML(非select)操作不commit,其他會話查詢該表資料時會產生額外的邏輯讀和redo,影響整個查詢時間 !
** 額外的消耗 要結合undo回滾表空間 思考...
【源於本人筆記】 若有書寫錯誤,表達錯誤,請指正...
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28602568/viewspace-1415926/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle點陣圖索引對DML操作的影響Oracle索引
- 【Oracle】-【COMMIT對索引的影響】-從trace看COMMIT對索引的影響OracleMIT索引
- SQLServer DML操作阻塞SELECT查詢SQLServer
- DDL,DML操作對結果快取的影響快取
- CONTEXT索引對COMMIT操作的影響 (ZT)Context索引MIT
- 16、MySQL Case-索引key對select count(*)的影響MySql索引
- Oracle優化案例-select中to_clob對效能的影響(二十一)Oracle優化
- JQuery 對 Select option 的操作jQuery
- unusable index對DML/QUERY的影響Index
- SQL學習筆記—非select操作SQL筆記
- SELECT也需要COMMITMIT
- Select for update/lock in share mode 對事務併發性影響
- MySQL alter 新增列對dml影響MySql
- Sql Server之旅——第十站 看看DML操作對索引的影響SQLServer索引
- oracle全文索引之commit與DML操作Oracle索引MIT
- 驗證資料壓縮對DML的影響
- javascript操作selectJavaScript
- jquery 操作selectjQuery
- shrink 操作對索引的影響索引
- Update操作對索引的影響索引
- Oracle 樹操作(select…start with…connect by…prior)Oracle
- oracle dbms_sql執行查詢select_dml_ddl(一)OracleSQL
- Js操作Select大全JS
- Oracle table selectOracle
- oracle select for updateOracle
- 有關Oracle表分割槽進行(DML)維護後對索引的影響的分析Oracle索引
- js 操作select和optionJS
- 關於drop操作對role的影響
- javascript操作Select中的options集合JavaScript
- 使用select監視update的操作
- Oracle Create Table as SelectOracle
- oracle分割槽表的常規操作導致對索引的影響Oracle索引
- Oracle中select ... for update的用法Oracle
- JavaScript操作select控制元件JavaScript控制元件
- reverse index 對於 MAX/MIN操作的影響Index
- golang當中對select的理解Golang
- Mysql加鎖過程詳解(4)-select for update/lock in share mode 對事務併發性影響MySql
- 為什麼忘記commit也會造成select查詢的效能問題(SELECT產生Redo的情形)MIT