数据库的作用就是实现对数据的管理和查询。任何一个数据库系统,必然存在对数据的大量读或者写或者两中操作都大量存在。IO问题也往往是导致数据库性能问题的重要原因。在这篇文章中,主要帮助大家在理解Oracle的读写操作机制的基础上,灵活解决遇到的各种常见的IO问题。
- 当服务进程扫描一定数量(阀值)的Buffer Cache后还没有找到干净、可重用的缓存块后,它会通知DBWn进程将“脏”数据写入文件中去,以释放出空闲缓存;
- 当发生检查点(Checkpoint)时。
- 当一个事务提交(COMMIT)时;
- 每3秒钟写一次Log Buffer;
- 当Log Buffer到达1/3满时;
- 当DBWn进程将“脏”数据写入磁盘时;
- 临时表/索引
- 排序
SQL> alter session set sort_area_size = 10000000;
Session altered.
SQL> select owner, object_name from t_test1
2 order by object_id;
47582 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1312425564
------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 47582 | 1486K| 155 (4)| 00:00:02 |
| 1 | SORT ORDER BY | | 47582 | 1486K| 155 (4)| 00:00:02 |
| 2 | TABLE ACCESS FULL| T_TEST1 | 47582 | 1486K| 150 (1)| 00:00:02 |
------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
1 recursive calls
0 db block gets
658 consistent gets
0 physical reads
0 redo size
1566184 bytes sent via SQL*Net to client
35277 bytes received via SQL*Net from client
3174 SQL*Net roundtrips to/from client
1 sorts (memory)
0 sorts (disk)
47582 rows processed
SQL> alter session set sort_area_size = 10000;
Session altered.
SQL> select owner, object_name from t_test1
2 order by object_id;
47582 rows selected.
Execution Plan
----------------------------------------------------------
Plan hash value: 1312425564
--------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes |TempSpc| Cost (%CPU)| Time|
--------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 47582 | 1486K| | 1251 (1)| 00:0
0:16 |
| 1 | SORT ORDER BY | | 47582 | 1486K| 4136K| 1251 (1)| 00:0
0:16 |
| 2 | TABLE ACCESS FULL| T_TEST1 | 47582 | 1486K| | 150 (1)| 00:0
0:02 |
---------------------------------------------------------------------------------
Statistics
----------------------------------------------------------
6 recursive calls
20 db block gets
658 consistent gets
629 physical reads
0 redo size
1566184 bytes sent via SQL*Net to client
35277 bytes received via SQL*Net from client
3174 SQL*Net roundtrips to/from client
0 sorts (memory)
1 sorts (disk)
47582 rows processed
- 临时LOB对象