http://www.laoxiong.net/table_scan_and_buffer_cache.html

全表扫描与buffer cache

https://www.cnblogs.com/Richardzhu/archive/2013/01/23/2872587.html

  1. 通过文档知道:

1.理论上,最大db_file_multiblock_read_count和系统IO能力应该有如下关系:

Max(db_file_multiblock_read_count) = MaxOsIOsize/db_block_size

当然这个Max(db_file_multiblock_read_count)还要受Oracle的限制。

2.DB_FILE_MULTIBLOCK_READ_COUNT  (数据库方面)

能否提高I/O 通道,由以下渠道的每个extent 大小(DB_FILE_MULTIBLOCK_READ_COUNT 一次不能跨越extent 读),如果是DB_FILE_MULTIBLOCK_READ_COUNT *(block_size)的整数倍,那么就是能有效的减少I/O 读写。

情况1:比如extent 由50个block 组成,DB_FILE_MULTIBLOCK_READ_COUNT =16 ,那么需要读 完整的extent 应该是 3次*16+1次*2 (共4次)共50个blocks。

情况2: 比如extent 由80个block 组成,DB_FILE_MULTIBLOCK_READ_COUNT =16 ,那么需要读 完整的extent 应该是 5次*16 共80个blocks。

如果同样的大小的表(400 blocks),情况1 一共需要 4*8个extent =32 个IO

如果同样的大小的表(400 blocks),情况2一共需要 5*5个extent=25 个IO   (更节约资源)

所以结论如下: 如果 单个exent 的block 数目 是DB_FILE_MULTIBLOCK_READ_COUNT的整数倍,更加提升I/O 性能。

  1.  
  1. DB_FILE_MULTIBLOCK_READ_COUNT
  1.  
  2. DB_FILE_MULTIBLOCK_READ_COUNT And Extents Management.
  3. -----------------------------------------------------
  4.  
  5. The Parameter 'db_file_multiblock_read_count' specifies the number
  6. of Oracle Blocks to be read in Single I/O Operation.
  7. DB_FILE_MULTIBLOCK_READ_COUNT should generally be made as large
  8. as possible.
  9. The value differs between platforms and versions, and usually
  10. depends on the settings of DB_BLOCK_SIZE and the maximum OS I/O Size.
  11.  
  12. EXTENT SIZING
  13. ===============
  14.  
  15. This parameter is normally used for multiblock reads for Full Table
  16. Scans and Fast Full Index Scans and normally can be used with CBO.
  17. The Oracle Extent Management can be tuned with this Parameter to get
  18. optimal benefit for I/O operation. Normally it is recommended that the
  19. entire Segment should be contained in Single Extent so that Full Table
  20. Scan or Fast Full Index Scan just have to traverse a single Extent.
  21. This will contribute to fast Query Operations.But as such, it is
  22. not a must.Even if the Segment is spread over Hundred or Thousands
  23. Of Extents and if the extents are of even size with proper
  24. db_file_multiblock_read_count defined, the Full Table Scan
  25. or Fast Full Index Scan still can improve performance.
  26.  
  27. The following Example will illustrate the above-mentioned fact:
  28.  
  29. Suppose a Table X currently occupies eight extents with the
  30. HWM (High Water Mark) in the eight extents.
  31. Each extent is evenly sized with 50blocks
  32. (db_block_size = 8K and Extent size 400k).
  33. The db_file_multiblock_read_count is set to 16.
  34.  
  35. -------------------------------------------------------------------------
  36. | | | | | | | | |
  37. ------ ------ ------ -------- -------- ---------- -------- <---HWM--->
  38. | | | | | | | | |
  39. -------------------------------------------------------------------------
  40. E1 E2 E3 E4 E5 E6 E7 E8
  41.  
  42. <-------------------- 50 blocks per extent ---------------------------->
  43.  
  44. Here E1 - E8 represents Extents each with 50 blocks.
  45. The HWM is in 389 Block. So 10 blocks are above the HWM since the
  46. first block is the Segment header block and total 400 blocks.
  47.  
  48. The Multiblock I/O never spans Extent Boundaries even if the Extents
  49. are contiguous and also if using Locally Managed Tablespaces.
  50. Assuming that none of the above blocks are in the Buffer Cache if we
  51. do Full Table Scan, then total 31 i/o operations will be required.
  52. Since each extent comprises of 50 blocks and 16 blocks read in single
  53. I/O operation.
  54. This means that 48-blocks/per extents will be read in 3 I/O operations
  55. whereas for the last remaining blocks one extra I/O has to be performed,
  56. in all making 4 I/O calls per Extent.This amounts to 28 I/O operations
  57. up to 7th Extent.
  58. The 8th Extent has 10 blocks above the HWM, so there will be only
  59. 3 i/o operations in the 8th Extent.
  60. (32 blocks in 2 i/os and remaining 8 blocks in 1 i/o )
  61.  
  62. *** The Extents size should always be a Multiple of
  63. db_file_multiblock_read_count ****
  64.  
  65. The Extents size should always be a Multiple of
  66. db_file_multiblock_read_count to take the advantage of Full Table
  67. Scans and Fast Full Index Scans.
  68. IF the extents of the Table X are made multiple of
  69. db_file_multiblock_read_count (80 blocks per extent), then only
  70. 5 Extents are required to manage the entire segment instead of
  71. 8 extents.
  72. Also since the extents are multiple of db_file_multiblock_read_count,
  73. the I/O operations are reduced from 31 to 25. There will only
  74. be 5 i/o operations per extent resulting in Total 25 I/O calls.
  75. Since each extent comprises of 80 blocks and multiblock_read_count=16,
  76. (16 * 5 = 80) each extent will require 5 I/O operations.
  77.  
  78. -------------------------------------------
  79. | | | | | |
  80. ------- ------- ------- -------- ---------
  81. | | | | | |
  82. ------- ------- ------- -------- ----------
  83. | | | | |<--HWM-->|
  84. --------------------------------------------
  85. E1 E2 E3 E4 E5
  86.  
  87. <----------- 80 blocks/Extent ------------>
  88.  
  89. Thus the i/o operations are reduced from 31 to 25 just by proper
  90. management of Extents. If the Extents size are a Multiple of
  91. db_file_multiblock_read_count, then i/o operations required will be
  92. less compared to when the Extents are not Multiple of
  93. db_file_multiblock_read_count.
  94.  
  95. Here, reducing the number of Extents have not reduced the I/O Calls
  96. but the multiple factor of Blocks per Extent with respect to
  97. Multiblock Read, have contributed to lessen the I/O calls.
  98.  
  99. Hence, even if the Segment comprises of Multiple Extents and if the
  100. extent size is a multiple of db_file_multiblock_read_count, the FTS
  101. will be faster.
  102. Remember that even if the Table X was composed of Single Extent
  103. of 400 blocks, it would take 25 i/os to read up to FTS.

As explained in the Oracle Documentation:

Oracle® Database Reference
12c Release 1 (12.1)
E17615-18     
DB_FILE_MULTIBLOCK_READ_COUNT
http://st-doc.us.oracle.com/12/121/server.121/e17615/refrn10037.htm#REFRN10037

DB_FILE_MULTIBLOCK_READ_COUNT is one of the parameters you can use to minimize I/O during table scans. It specifies the maximum number of blocks read in one I/O operation during a sequential scan. The total number of I/Os needed to perform a full table scan depends on such factors as the size of the table, the multiblock read count, and whether parallel execution is being utilized for the operation.

The default value of this parameter is a value that corresponds to the maximum I/O size that can be performed efficiently. This value is platform-dependent and is 1MB for most platforms.

Because the parameter is expressed in blocks, it will be set to a value that is equal to the maximum I/O size that can be performed efficiently divided by the standard block size. Note that if the number of sessions is extremely large the multiblock read count value is decreased to avoid the buffer cache getting flooded with too many table scan buffers.

Even though the default value may be a large value, the optimizer will not favor large I/Os if you do not set this parameter. It will favor large I/Os only if you explicitly set this parameter to a large value.

Online transaction processing (OLTP) and batch environments typically have values in the range of 4 to 16 for this parameter. DSS and data warehouse environments tend to benefit most from maximizing the value of this parameter. The optimizer is more likely to choose a full table scan over an index if the value of this parameter is high.

The maximum value is the operating system's maximum I/O size expressed as Oracle blocks ((max I/O size)/DB_BLOCK_SIZE). If you set this parameter to a value greater than the maximum, then Oracle uses the maximum.

From Oracle 10gR2, DB_FILE_MULTIBLOCK_READ_COUNT is automatically set depending on:

  • operating system optimal I/O size
  • the size of the buffer cache
  • the maximum number of sessions

The formula for calculating DB_FILE_MULTIBLOCK_READ_COUNT is calculated by hidden parameter _db_file_optimizer_read_count. db_file_optimizer_read_count equals db_file_multiblock_read_count when the latter is explicitly set, but equals 8 when not. Review following note:

Document 1106073.1 What is the difference between '_db_file_optimizer_read_count' and 'db_file_multiblock_read_count'?

As stated above, even if the value calculated by Oracle is large, the optimizer will not favour large full table scans unless DB_FILE_MULTIBLOCK_READ_COUNT is explicitly set to a large value.


TIP: It is recommended to leave the value unset so that Oracle will compute the value.

If set, the behavior is consistent to behavior prior to 10gR2.

DB_FILE_MULTIBLOCK_READ_COUNT can be unset by following the information in the following note:

Document 473740.1 How To Unset DB_FILE_MULTIBLOCK_READ_COUNT to Default Value

Without WORKLOAD stats, CBO computes multiblock reads as:

io_cost = ceil(blocks * 0.5965/_db_file_optimizer_read_count0.6582)

(The NOWORKLOAD case, the following are used in the formula:
MBRC = _db_file_optimizer_read_count (if system stat MBRC is not gathered)
SREADTIM = IOSEEKTIM + db_block_size/IOTFRSPEED
MREADTIM = IOSEEKTIM + MBRC * db_block_size/IOTFRSPEED))

 

NOTE: In 10g, CPU costing is always used unless explicitly disabled, so this formula is almost never used.  In 9i (or if Optimizer feature enabled is set to 9.x), CPU costing is used only when WORKLOAD stats are gathered.  

With WORKLOAD stats, then:

io_cost = max(1, ceil(blocks/MBRC * MREADTIM/SREADTIM))

(The workload stats come straight from the WORKLOAD system statistics)

转 db_file_multiblock_read_count的更多相关文章

  1. DB_FILE_MULTIBLOCK_READ_COUNT对物理读和IO次数的影响

    当执行SELECT语句时,如果在内存里找不到相应的数据,就会从磁盘读取进而缓存至LRU末端(冷端),这个过程就叫物理读.当相应数据已在内存,就会逻辑读. 物理读是磁盘读,逻辑读是内存读:内存读的速度远 ...

  2. Oracle Tuning 基础概述01 - Oracle 常见等待事件

    对Oracle数据库整体性能的优化,首先要关注的是在有性能问题时数据库排名前几位等待事件是哪些.Oracle等待事件众多,随着版本的升级,数量还在不断增加,可以通过v$event_name查到当前数据 ...

  3. Oracle启动报错ORA-27102解决

    环境:RHEL5.5 + Oracle 10.2.0.4 此错误一般是因为数据库的初始化参数文件的内存设置不当导致.本例是因为操作系统参数设置问题导致. 当前现象:Oracle启动报错ORA-2710 ...

  4. ORACLE的SPFILE与PFILE

    ORACLE中的参数文件是一个包含一系列参数以及参数对应值的操作系统文件,可以分为两种类型.它们是在数据库实例启动时候加载的,决定了数据库的物理结构.内存.数据库的限制及系统大量的默认值.数据库的各种 ...

  5. Oracle的优化器介绍

    Oracle优化器介绍 本文讲述了Oracle优化器的概念.工作原理和使用方法,兼顾了Oracle8i.9i以及最新的10g三个版本.理解本文将有助于您更好的更有效的进行SQL优化工作. RBO优化器 ...

  6. ORACLE工作原理小结

    ORACLE工作原理1-连接 我们从一个用户请求开始讲,ORACLE的完整的工作机制是怎样的,首先一个用户进程发出一个连接请求,如果使用的是主机命名或者是本地服务命中的主机名使用的是机器名(非IP地址 ...

  7. 数据库服务器CPU持续百分之百、部分Session一直处于执行状态---等待事件为:asynch descriptor resize(Oracle Bug )

    问题描述: 项目反馈数据库服务器的CPU持续100%的情况,跟踪发现很多活动会话的等待事件是“asynch descriptor resize”,并且这些会话一直处于Active状态,而这些会话执行的 ...

  8. sqlserver和Oracle内部的错误数据修复(DBCC、DBMS_REPAIR)

    数据库长时间运行后,因断电.操作系统.物理存储等的原因可能会造成数据库内部的逻辑或物理错误,我们可以使用一般的方式尝试修复. 对于sqlserver 我们可以使用DBCC命令: -- sqlserve ...

  9. ORACLE10gRAC数据库迁移至10gRAC

    1.数据库备份RUN {ALLOCATE CHANNEL ch00 DEVICE TYPE disk;ALLOCATE CHANNEL ch01 DEVICE TYPE disk;ALLOCATE C ...

随机推荐

  1. 运算符-----------instanceof

  2. 1080 Graduate Admission (30)(30 分)

    It is said that in 2013, there were about 100 graduate schools ready to proceed over 40,000 applicat ...

  3. [POI 2000] 公共串

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2946 [算法] 建立多串后缀树 对于后缀树上的每个点 , 判断该节点所代表的等价类是 ...

  4. Django 发送email配置详解及各种错误类型

    跟随Django Book的内容发送邮件不成功,总结一下需要配置好settings.py文件,还要注意一些细节. 1.在settings文件最后添加以下内容,缺一不可! EMAIL_HOST= 'sm ...

  5. poj2356Find a multiple——鸽巢定理运用

    题目:http://poj.org/problem?id=2356 N个数,利用鸽巢定理可知应有N+1个前缀和(包括0),因此其%N的余数一定有重复: 同余的两个前缀和之差一定为N的倍数,据此得出答案 ...

  6. C# GUID使用总结

    全局唯一标识符(GUID,Globally Unique Identifier) What is GUID 也称作 UUID(Universally Unique IDentifier) . GUID ...

  7. Linux中的nc测试端口是否开放

    nc测试端口是否开放 在Linux中有一个级强大的网络工具netcat,在默认情况下面都是没有安装的,现在介绍一下安装过程 其实安装很简单 一.安装使用 1.只需输入命令yum安装: [root@SZ ...

  8. valgrind 代码检查,内存泄漏

    使用平台 linux 下载 http://valgrind.org/ 文档 http://valgrind.org/docs/manual/manual.html 博客 https://www.osc ...

  9. pkg_resources----Entry Points为程序提供扩展点

    官方文档对Entry Points的介绍 Entry Points Entry points are a simple way for distributions to "advertise ...

  10. 原生app与WebApp的区别

    Native App开发Native App开发即我们所称的传统APP开发模式(原生APP开发模式),该开发针对IOS.Android等不同的手机操作系统要采用不同的语言和框架进行开发,该模式通常是由 ...