Sizing Extents for Performance

本文探讨了Oracle数据库中扩展区对性能的影响。介绍了通过RowID和全表扫描两种读取数据的方法,指出RowID读取与扩展区分配无关,全表扫描受其影响。还分析了扩展区位置在操作系统层面的影响,以及多个扩展区的好处,如利于数据分布和并行查询等。

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

Sizing Extents for Performance

           This is an edited excerpt from ORACLE8 Advanced Tuning and Administration, by Eyal Aronoff, Kevin Loney, and Noorali Sonawalla, published under Osborne/McGraw-Hill's Oracle Press imprint.  This edited version first appeared on http://www.kevinloney.com.

 


              Extents are often blamed for performance problems; however, their impact on performance is minimal and can be completely avoided. In fact, careful use of extents can improve your response time by distributing your I/O operations across multiple devices. To understand the impact of extents on performance, you need to consider the two different methods of reading data from a table: by RowID and by full table scan.

              Oracle's preferred method of reading records for OLTP applications is by the row's RowID value. For example, an index range scan may generate a list of RowIDs that match a query's limiting condition. The query in the following listing would perform a range scan on the SALES table's primary key index (a two-column composite index on the Company_ID and Period_ID columns).

select *
  from SALES
 where Company_ID > 100;

Since all columns are selected from the SALES table, the index alone cannot satisfy the query. Once the index has been scanned for the RowID values for rows that meet the limiting condition on the Company_ID column, the SALES table will be accessed via a TABLE ACCESS BY ROWID operation.

           In Oracle7, the RowID pseudo-column has three components. The RowID components are, in order: a block number (of the block within the file), a sequence number (of the row within the block), and a file number (of the file within the database). For example, the RowID 00001234.0000.0009 corresponds to the first row (sequence number 0000) in block 00001234 of file 09 (note that the numbers are in hexadecimal). Once Oracle has the RowID for a row, it knows exactly which block of which file the row is located in, and it knows exactly where within the block the row resides.

            In Oracle8, the extended RowID format is available. In the extended RowID format, the size of each part of the RowID has been increased to support a greater number of files and blocks per file. Additionally, the data object identifier was added to the RowID. When displaying an extended RowID, a base-64 character string is returned. For example, the following query shows the new RowID and its parts:

select RowID,
       DBMS_ROWID.ROWID_OBJECT(RowID) Object,
       DBMS_ROWID.ROWID_RELATIVE_FNO(RowID) File_No,
       DBMS_ROWID.ROWID_BLOCK_NUMBER(RowID) Block,
       DBMS_ROWID.ROWID_ROW_NUMBER(RowID) RowNo
  from dual;
 
ROWID                 OBJECT   FILE_NO     BLOCK     ROWNO
------------------ --------- --------- --------- ---------
AAAACsAABAAAATmAAA       172         1      1254         0

                The first six base-64 digits are for the object number. In the extended RowID, ‘A’ stands for zero, ‘B’ for 1, ‘C’ for 2, and ‘s’ for 44. Therefore, the object number AAAACs in base 64 is equal to 2*64+44=172, which matches the Object_ID value returned by the ROWID_OBJECT procedure. The next three base-64 digits are the relative file number (AAB=1). The next six digits are the block number, and the last three digits are the row number inside the block.

                 What the RowID does not contain—information regarding the extent in which the row resides—is just as significant as what it does contain. Accesses to the table that use a RowID-based method, such as indexed-based accesses, are blind to the extent allocation within the segment. Extents only impact full table scans.

Note: The following comparison of the extent size with respect to I/O size for saving I/O is significant only when the I/O size (64KB) and the extent size are of the same order of magnitude. It becomes insignificant if I/O size is much less than extent size.

              During a full table scan, Oracle uses its multiblock read capability to scan multiple blocks at a time. The number of blocks read at a time is determined by the database's DB_FILE_MULTIBLOCK_READ_COUNT setting in the init.ora file and by the limitations of the operating system's read buffers. For example, if you are limited to a 64KB buffer for the operating system, and the database block size is 4KB, you can read no more than 16 database blocks during a single read.

                    Consider the SALES table again, with an 8MB initial extent and a 4MB second extent. For this example, assume that the highwatermark of SALES is located at the end of the second extent. In the first extent, there are 2048 database blocks, 4KB each in size (8 MB/4 KB = 2048). During a full table scan, those blocks will be read 16 at a time, for a total of 128 reads (2048/16 = 128). In the second extent, there are 1024 database blocks. During a full table scan, those blocks will be read 16 at a time, for a total of 64 reads (1024/16=64). Thus, scanning the entire table will require 192 reads (128 for the first extent, plus 64 for the second extent).

                      What if the two extents were combined, with the table having the same highwatermark? The combined extent would be 12MB in size, consisting of 3072 database blocks. During a full table scan, those blocks will be read 16 at a time, for a total of 192 reads. Despite the fact that the extents have been compressed into a single extent, the exact same number of reads is required because of the way the extents were sized. As you will see in the next section, the location of the extents may influence the efficiency of the reads, but the number of reads is the same in both the single- and two-extent examples.

                      What if SALES had 192 extents, each one 16 blocks in length? A full table scan would read 16 blocks at a time, for a total of 192 reads. Thus, whether the SALES table had 1, 2, or 192 extents, the exact same number of reads was required to perform the full table scan. The size of the extents is critical—the size of each extent must be a multiple of the number of blocks read during each multiblock read (set via the DB_FILE_MULTIBLOCK_READ_COUNT init.ora parameter value).

 

                 In the 192-extent example, the extent size matched the setting of the DB_FILE_MULTIBLOCK_READ_COUNT value (16). If each extent had been 20 blocks (instead of 16 blocks), how many reads would be required?

The SALES table contains 3072 blocks of data (12MB total). If each extent is 20 blocks (80 KB) each, you'll need 154 extents to store the 3072 blocks of data. When reading the first extent during a full table scan, Oracle will read the first 16 blocks of the extent (as dictated by the DB_FILE_MULTIBLOCK_READ_COUNT). Because there are four blocks left in the extent, Oracle will issue a second read for that extent. Reads cannot span extents, so only four blocks are read by the second read. Therefore, the 20-block extent requires two reads. Since each extent is 20 blocks in length, each extent will require two reads. Because there are 154 extents, a full table scan of SALES will now require 308 reads—a 60 percent increase over the 192 reads previously required!

                  As shown in Table 1, the number of extents in a table does not affect the performance of full table scans of the table as long as the size of the extents is a multiple of the size of each read that is performed.

Size of extents

Number of extents

Number of reads required by a full table scan

12MB

1

192

8MB, 4MB

2

192

64KB

192

192

80KB

154

308

Table 1: Impact of Extent Sizes on Full Table Scans

The examples listed in Table 1 show two important facts about extents relative to performance:

1.               If the extents are properly sized, the number of extents has no impact on the number of reads required by table scans.

2.                  If the extents are not properly sized, the number and size of the extents can greatly increase the amount of work performed by the database during a full table scan.

                  Proper sizing of extents is a key factor in managing the performance of full table scans. To eliminate the potential impact of multiple extents on performance, you need to make sure that the size of each extent is a multiple of the number of blocks read during each multiblock read. In many systems, 64KB or 128KB is read during each read (in the SALES example, 64KB was used). Therefore, size your extents so that each is an even multiple of 64KB or 128KB. As shown in Table 1, choosing an extent size that is not an even multiple of this value (such as 80KB) can increase the amount of work performed during a full table scan. If the extents are properly sized, there is no impact on the required number of reads.

               Although increasing the number of extents does not necessarily increase the number of reads required, the complexity of managing the impact of extents increases as the number of extents increases. Consider, for example, the size of the extents; although you may calculate them to minimize the number of unnecessary reads, Oracle may dynamically change the extent size based on its rounding functions. The only way to reduce the effect of dynamic space allocation rounding is to reduce the number of extents.

                     Database objects frequently read via large scans—either full table scans or large index range scans—should be stored in a small number of extents. The additional extents, if properly sized, will not negatively impact performance. Keeping the number of extents small makes it more likely that the next

data to be read is physically near the data currently being read.

Location of Extents

 

                    If having multiple properly sized extents does not necessarily hurt your performance at the database level, what impact does it have at the operating-system level?

There is no way to guarantee (from within the database) that the datafiles you create are located on contiguous areas of disk. Thus, two consecutive blocks within the same extent may be physically located on different sections of the same disk.

                    If the blocks of a datafile were all contiguous on a disk, then each time you completed one read, the disk hardware would be properly positioned to execute the next read. But since there is no guarantee that the data you are reading from a single extent is contiguous on the disk, there is no guarantee that the disk hardware is properly positioned for the next read regardless of the number of extents in the table. Any potential benefit from disk hardware positioning is therefore eliminated unless you can guarantee that the file is located on a contiguous area on a disk. If you create a new file system on a new disk, and create a datafile as the first file in that file system, you increase the likelihood that the file's blocks are physically contiguous.

                         If a database object is not read by large scans, the number of extents has no impact on the performance of queries against it. In OLTP applications, the typical access to database files is via random "hot-spot" reads; the efficiency of the reads may be improved if the hot spots are near each other, but the number of extents in which the hot spots are stored makes little difference to the performance of the data accesses. When designing your database to take advantage of the physical location of data, you need to be aware of the I/O management techniques in use on the server. The advanced I/O management techniques available, such as RAID technologies, use striping methods to split a file across multiple disks—so data that appears to be on the same device is actually stored on separate disks. Because RAID systems distribute data from the same file across multiple disks, you cannot be certain of the physical location of a data hot spot, nor that two hot spots are stored on the same disk.

The Benefits of Multiple Extents

 

                 Having a single extent may make an object simple to manage—provided the object fits into a single datafile. However, forcing each object in your database to have just one extent will yield little in the way of performance improvements, and may actually hurt performance.

               If you have only one extent in the SALES table, you cannot stripe the SALES data within the database. The SALES table would be stored in a single datafile and, by extension, on a single disk. All queries against SALES will use the same disk, and you will be unable to distribute the I/O operations across multiple disks unless you use some form of operating system-level striping.

              If you have only one extent for SALES, you will not be able to effectively use the Parallel Query option (PQO) for queries against the table. In the PQO, multiple processes concurrently perform the work of a query. If the data queried by the multiple processes is all located on the same disk, using the PQO for queries of the data may create an I/O bottleneck on the disk!

                       Lastly, having a single extent for an object prevents you from using the available extents to determine the growth rate for an object. For example, if you create a large initial extent for a small business transaction table, you will have to periodically check the number of rows in the table in order to determine its growth rate. If the extents were more reasonably sized, you would be able to determine its growth pattern by checking its extent allocations. Also, a single large extent wastes space within the object. Although you can reclaim allocated space as of Oracle7.3, there is usually little benefit to preallocating large volumes of unused space.  

           If the size of each extent is a multiple of the data volume read during a single multiblock read from the database, there is no performance penalty for using multiple extents—and if you are using database striping or PQO methods, there is potential performance benefit. You can use the maxextents unlimited clause to allow your objects to have over two billion extents—but such a high number is difficult to manage and can significantly impact the performance of DDL that updates extent information (such as drop table). Although multiple extents do not have to hurt your performance, they can make your database more difficult to administer. For database tables that will grow—primarily the business transaction tables—monitor their extent allocation and determine their growth rate. If the business transaction tables extend no more often than once every few months, the management effort required for them will remain low.

 

 

 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/35489/viewspace-84248/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/35489/viewspace-84248/

开发板推荐:天空星STM32F407VET6开发板

超高性价比 STM32主控 | 超高主频 | 一板兼容百芯 | 比赛神器 | 沉金彩色丝印

源码链接: https://pan.quark.cn/s/a4b39357ea24 斐讯K2是一款广受用户青睐的无线路由器,其运行表现稳定且具备较高的可操作性,在DIY爱好者群体中拥有极高的声誉。本资料将系统性地阐述斐讯K2的固件刷机方法及其关联的技术要点。固件升级是路由器爱好者改善设备性能、扩展功能的一种普遍手段,经由替换出厂固件,能够达成更加个性化的网络配置、增强安全防护等目标。斐讯K2固件资源库涵盖了多种知名的非官方固件,诸如Tomato Pheonix 不死鸟、高恪、PandoraBox 潘多拉等,这些固件均具备独特的优势,能够适配不同用户的需求。 1. Tomato Pheonix 不死鸟:Tomato是一款立足于Linux的开源固件,以其精巧、高效而备受推崇。不死鸟版本是专门为华硕及斐讯路由器优化的分支,提供了卓越的QoS(服务质量)配置、详尽的图表监控以及便捷的固件升级途径。对于那些需要精准调控带宽和监测网络状态的用户而言,这是一个理想的选项。 2. 高恪:高恪固件是OpenWrt的定制化版本,着重于操作的便捷性和运行的可靠性,特别适合对路由器操作不甚熟悉的用户群体。它提供了一些实用的功能,例如内置的广告屏蔽、快速测速工具等,同时保留了OpenWrt的适应性。 3. PandoraBox 潘多拉:潘多拉盒是另一款基于OpenWrt的固件,它以丰富的插件库和强大的自定义潜力而闻名。用户能够依据个人需求安装各类插件,实现更多功能,如远程接入、DDNS(动态域名解析服务)等。 4. 官方固件的纯净版本与定制版本:官方固件通常更侧重于稳定性,纯净版意味着未预置额外的应用或服务,适合注重稳定性的用户。定制版则可能包含了制造商的特色功能或优...
源码下载地址: https://pan.quark.cn/s/926926948560 AS3.0与XML结合的通用图片滚动功能,是一种基于ActionScript 3.0和XML技术的动态图像展示方案,非常适合初学者进行学习和实践应用。此项目的关键在于借助XML文件作为数据媒介,用来保存图像的相关参数,例如图像的链接地址、展示的次序等,接着在AS3.0环境中对XML进行解析,并动态地载入和展示这些图像,达成图像的滚动或是循环播放的目的。 我们需要明确ActionScript 3.0(AS3.0)是Adobe Flash Professional以及Flex Builder等开发工具中采用的编程语言,用于构建交互式内容以及丰富的互联网应用。相较于先前的版本,AS3.0在性能上有了大幅度的提升,并且引入了更为规范的面向对象编程模式,涵盖了类、接口以及包等概念。 XML(可扩展标记语言)是一种简明且高效的数据传输格式,既便于人类阅读和编写,也易于机器进行解析和生成。在该项目中,XML文件用于存储图像数据,例如图像的URL、延时的时长、动画的样式等,通过这种方式可以将数据与程序代码分离,从而增强代码的可维护性与可扩展程度。 实施这一图片滚动功能,主要涉及到以下AS3.0的核心知识点: 1. **XML解析**:运用`XML`类来载入并解析XML文件,从而获取图像的清单。AS3.0提供了简便的API来操作XML节点,例如`children()`、`attributes()`等,用以获取子节点和属性值。 2. **事件监听**:借助`EventDispatcher`类来监控载入和解析过程中的事件,比如`Event.OPEN`、`Event.PROGRESS`、`Event...
内容概要:本文介绍了软件许可管理的技术实现方式及相关工具资源,重点阐述了加密外壳(EMS)和API加密两种保护机制。加密外壳通过将程序(如.exe、.dll、.apk)封装在加密壳中,实现运行时内存解密,防止静态反编译和代码篡改,同时支持对数据文件、系统参数及部分代码的加密,并依赖硬件锁(HL)或软件锁(SL)进行授权控制。API加密则通过在代码中嵌入安全验证调用,确保授权合法后才执行核心逻辑。文章还说明了锁的类型(HL/SL)、模式(有驱/AdminMode与无驱/UserMode)、升级路径以及虚拟时钟功能,并描述了产品授权流程从功能定义到产品创建、授权生成的全过程,支持通过C2V文件或锁ID复制已有授权状态。文中附带多个开源平台链接和技术博客参考资源。; 适合人群:从事软件版权保护、授权系统开发或安全技术研究的研发人员,尤其是具备一定逆向工程、软件安全基础的1-3年经验开发者。; 使用场景及目标:①构建安全的软件授权体系,防止盗版和非法使用;②实现灵活的功能授权管理(如时效、并发、硬件绑定);③选择合适的加密方案(硬件锁/软锁、有驱/无驱)并集成到现有产品中;④学习加密外壳与API验证的实际应用方法; 阅读建议:此资源侧重于软件许可的技术架构与实施细节,建议结合提供的GitHub、Gitee项目链接及CSDN技术文章深入理解实现原理,并通过实际调试加密壳和模拟授权流程加强实践能力。
内容概要:本文聚焦于“风光制氢合成氨系统优化研究”,系统阐述了基于Cplex求解器对该耦合系统进行数学建模与优化求解的全过程,并提供了完整的Matlab代码实现。研究整合风能、光伏等可再生能源发电与电解水制氢、合成氨化工工艺,构建涵盖系统容量配置与运行调度的联合优化模型,旨在提升绿电就地消纳水平、降低碳排放强度并实现综合能源利用效率的最大化。文中详细解析了优化模型的核心构成,包括以综合成本最小化或能源效率最大化为目标的目标函数设计,以及涵盖设备出力能力、系统能量动态平衡、设备启停特性等关键环节的约束条件建模方法,利用Cplex求解器进行高效精确求解,模型适用于并网与离网等多种运行场景。; 适合人群:具备一定能源系统建模与优化理论基础,熟练掌握Matlab编程语言及常用优化工具箱(如YALMIP)应用的科研人员与工程技术从业者,特别适用于从事综合能源系统规划、绿色氢能与绿氨生产、可再生能源高效集成等前沿领域的硕士、博士研究生及高校科研人员。; 使用场景及目标:①复现高水平学术论文中关于风光制氢合成氨系统的复杂优化模型;②深入掌握Cplex求解器在大规模、多约束能源系统优化问题中的高级建模与调用技巧;③开展面向“双碳”战略的绿氢、绿氨生产项目的可行性分析、规划设计与运行策略研究,为清洁能源项目的科学决策与工程落地提供量化依据和技术支撑。; 阅读建议:建议读者结合文中提供的Matlab代码与相关领域的权威文献进行对照学习,重点剖析模型构建的物理逻辑与数学推导过程,熟练掌握Cplex与Matlab的接口调用方法;鼓励读者通过调整系统参数、修改目标函数或扩展模型结构(如引入更多不确定性因素)等方式进行二次开发,以适应不同的实际应用场景,进一步深化对综合能源系统优化的理解与实践能力。
打开链接下载源码: https://pan.quark.cn/s/a4b39357ea24 本资源汇编了数据结构实验的上机任务解答,涵盖了代码实现以及详尽的注释说明。以下是对相关知识的梳理: 1. 数据结构实验:该文档呈现了数据结构实验的上机任务解答,包含代码实现与详尽的注释说明。此实验旨在评估学生对数据结构的掌握程度及编程能力。 2. 结构体数组:在C++语言中,结构体数组是一种常见的数据组织形式。结构体数组能够存储大量数据,并支持灵活的操作。在本资源中,结构体数组被用于存储赫夫曼树的节点信息。 3. 赫夫曼树:赫夫曼树是一种特殊的二叉树结构,其每个节点的权值等于其左右子树的权值之和。赫夫曼树在数据压缩、编码与解码等领域具有广泛的应用。在本资源中,赫夫曼树被用于实现数据的编码与解码功能。 4. 选择函数:选择函数是赫夫曼树的关键算法之一,负责选取赫夫曼树的根节点与叶节点。在本资源中,选择函数通过递归算法来选取赫夫曼树的根节点与叶节点。 5. 创建赫夫曼树:构建赫夫曼树是赫夫曼编码的核心步骤。在本资源中,采用递归算法来构建赫夫曼树,并将其存储在结构体数组中。 6. 赫夫曼编码:赫夫曼编码是一种可变长度的编码方式,利用赫夫曼树表示符号的频率信息。在本资源中,赫夫曼编码被用于对输入字符串进行编码,并存储在字符数组中。 7. 字符串操作:字符串操作是C++语言的基础功能之一。在本资源中,通过字符串操作实现字符串的连接与截取等操作。 8. 输入输出操作:输入输出操作是C++语言的基础功能之一。在本资源中,利用输入输出操作读取输入数据并输出结果。 9. 指针操作:指针操作是C++语言的基础功能之一。在本资源中,通过指针操作实现动态内存分配和...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值