热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

碎片1

本文对Oracle在磁盘、表空间,表、索引方面的碎片问

这篇文章一开始只是一个坚果,后来我意识到它将更像一个椰子而不是榛子,于是决定把它变成一个短篇的系列。在接下来的两周内,我将发布以下四个部分:

1、简介(本篇)

2、磁盘和表空间碎片

3、表碎片

4、索引碎片


一、简介

“碎片”一词的含义,是指某物被分成零碎的小片,但是它也带有一种情感色彩,暗示它是许多小的片段。在Oracle语境下,你需要考虑片段的含义,片段的粒度和可能对性能的影响。由于我们可能在(逻辑)磁盘级别,文件级别,表空间级别,段级别,分区(extent)级别和块级别讨论它,因此当您说“我的表空间已碎片化”或“我的索引已碎片化”之类的表述时,有必要非常清楚地要说明白。

让我们从一个例子开始:我创建了一个新的表空间,并将一个表移入。当我从DBA_EXTENTS中发现它有100个extents时,显然,从字面含义上看,它是“碎片”化的,因为它是由100个不同的片段组成的。另一方面,由于该表是我在表空间上创建的第一个表,我可以发现所有的片段是相邻的。所以,你可以说表是“逻辑上是碎片化”的,但“物理上是连续的”。

这个例子中的碎片,会对你的系统性能有影响吗?由于Oracle的IO操作大多数都是块级别的(我们读数据块到DB CACHE,写数据块到文件),而且这和块在特定extent中的位置是不相关的,所以,回答也许是否定的。但是,有时候,我们在单独一次读请求中,要尝试读取多个相邻的块(比如表扫描和索引快速全扫);那么“物理上连续的”的表被“逻辑上分割”成许多extents上,会有问题吗?

如果每个extents只有64KB,这是否限制了“db file multiblock read” 请求的大小,或者这些请求是否可以跨越extents的边界?如果表空间是由两个(或更多)文件组成的,因此,extents通常是在两个文件上交替分配的。这是否会影响读取操作的方式?如果我们尝试做一个并行的表扫描,直接路径读上的限制是否有所不同?如果你在数据仓库上花费了大量的时间进行这类操作,那么这些会是需要你回答的一部分问题。(例如,请参阅我三年前写的一篇关于运行并行查询时I/O大小异常的说明https://jonathanlewis.wordpress.com/2007/05/29/autoallocate-and-px/ 译文链接,以及几年后Christian Antognini在11g中描述的相关功能增强。http://antognini.ch/2009/08/system-managed-extent-size-11g-improvements/ 译文链接)

只有在你开始清楚地思考“碎片化”的含义之后,你才能开始理解它可能导致的问题,以及它会或不会对你的系统产生影响的原因。在第二部分中,我将对您在磁盘级和表空间级考虑碎片化的问题做一些说明。

以下附原文及链接:

https://jonathanlewis.wordpress.com/2010/07/13/fragmentation-1/

Fragmentation 1

Filed under: fragmentation,Infrastructure,Oracle — Jonathan Lewis @ 8:33 pm BST Jul 13,2010

This note started life as a nutshell until I realised that it was going to be more of a coconut than a hazel nut and decided to turn it into a short series instead. I should manage to post four parts over the next two weeks:

Introduction (this bit)

Disk and Tablespace Fragmentation

Table Fragmentation

Index Fragmentation

Introduction

The implication of the word “fragmentation” is that something is broken into pieces, but it also carries an emotional overtone that suggests it’s lots of little pieces. In an Oracle context you need to consider what you mean by “pieces”, the granularity of the pieces, and the possible impact on performance. Since it’s possible to talk about fragmentation at the (logical) disk level, the file level, the tablespace level, the segment level, the extent level, and the block level, it’s necessary to think very clearly about what you’re trying to say when you make a comment like “my tablespace is fragmented” or “my index is fragmented”.

Let’s start with an example: I have created a new tablespace and moved a table into it. When I check dba_extents the table has 100 extents. Clearly it is “fragmented” in the basic sense of the word since it is made of 100 different pieces. On the other hand, because the table was the first thing I created in the tablespace, I can see that all the extents are adjacent – so you could say the table is “logically fragmented” but “physically contiguous”.

Does this example of fragmentation have any impact on the performance your system ? Since most I/O done by Oracle operates at the block level (we read data blocks into the db cache, we write data blocks to files), and the location of the block within any particularly extent is irrelevant, the answer is probably no. But there are times when we try to read multiple adjacent blocks with a single read request (tablescans and index fast full scans); does it matter that our “physically contiguous” table is “logically fragmented” into lots of extents ?

What if the extents are (say) only 64KB each, does this limit the size of the “db file multiblock read” requests that we will be making or can those reads cross extent boundaries ? What if the tablespace is made up of two (or more) files so that the extents generally “round-robin” between files – does this affect the way the reads can operate ? What if we try to do a parallel tablescan -are the restrictions on “direct path reads” different ? If you’re running a datawarehouse that spends a lot of its time doing this type of operation then these are just some of the questions you need to answer. (See, for example, a note I wrote three years ago about some of the anomalies of I/O sizes when running parallel query, and a related enhancement in 11g described by Christian Antognini a couple of years later.)

It’s only after you start to think clearly about what you mean by “fragmentation” that you can begin to understand the possible problems that it can cause and the reasons why it may, or may not, have an impact on your system. In part two I’ll make some comments about the way you should think about fragmentation at the disk level and the tablespace level.



推荐阅读
  • EPICS Archiver Appliance存储waveform记录的尝试及资源需求分析
    本文介绍了EPICS Archiver Appliance存储waveform记录的尝试过程,并分析了其所需的资源容量。通过解决错误提示和调整内存大小,成功存储了波形数据。然后,讨论了储存环逐束团信号的意义,以及通过记录多圈的束团信号进行参数分析的可能性。波形数据的存储需求巨大,每天需要近250G,一年需要90T。然而,储存环逐束团信号具有重要意义,可以揭示出每个束团的纵向振荡频率和模式。 ... [详细]
  • Iamtryingtomakeaclassthatwillreadatextfileofnamesintoanarray,thenreturnthatarra ... [详细]
  • 云原生边缘计算之KubeEdge简介及功能特点
    本文介绍了云原生边缘计算中的KubeEdge系统,该系统是一个开源系统,用于将容器化应用程序编排功能扩展到Edge的主机。它基于Kubernetes构建,并为网络应用程序提供基础架构支持。同时,KubeEdge具有离线模式、基于Kubernetes的节点、群集、应用程序和设备管理、资源优化等特点。此外,KubeEdge还支持跨平台工作,在私有、公共和混合云中都可以运行。同时,KubeEdge还提供数据管理和数据分析管道引擎的支持。最后,本文还介绍了KubeEdge系统生成证书的方法。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文介绍了数据库的存储结构及其重要性,强调了关系数据库范例中将逻辑存储与物理存储分开的必要性。通过逻辑结构和物理结构的分离,可以实现对物理存储的重新组织和数据库的迁移,而应用程序不会察觉到任何更改。文章还展示了Oracle数据库的逻辑结构和物理结构,并介绍了表空间的概念和作用。 ... [详细]
  • 本文介绍了南邮ctf-web的writeup,包括签到题和md5 collision。在CTF比赛和渗透测试中,可以通过查看源代码、代码注释、页面隐藏元素、超链接和HTTP响应头部来寻找flag或提示信息。利用PHP弱类型,可以发现md5('QNKCDZO')='0e830400451993494058024219903391'和md5('240610708')='0e462097431906509019562988736854'。 ... [详细]
  • PDO MySQL
    PDOMySQL如果文章有成千上万篇,该怎样保存?数据保存有多种方式,比如单机文件、单机数据库(SQLite)、网络数据库(MySQL、MariaDB)等等。根据项目来选择,做We ... [详细]
  • 本文介绍了OpenStack的逻辑概念以及其构成简介,包括了软件开源项目、基础设施资源管理平台、三大核心组件等内容。同时还介绍了Horizon(UI模块)等相关信息。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • Python正则表达式学习记录及常用方法
    本文记录了学习Python正则表达式的过程,介绍了re模块的常用方法re.search,并解释了rawstring的作用。正则表达式是一种方便检查字符串匹配模式的工具,通过本文的学习可以掌握Python中使用正则表达式的基本方法。 ... [详细]
  • 关键词:Golang, Cookie, 跟踪位置, net/http/cookiejar, package main, golang.org/x/net/publicsuffix, io/ioutil, log, net/http, net/http/cookiejar ... [详细]
  • 如何在php中将mysql查询结果赋值给变量
    本文介绍了在php中将mysql查询结果赋值给变量的方法,包括从mysql表中查询count(学号)并赋值给一个变量,以及如何将sql中查询单条结果赋值给php页面的一个变量。同时还讨论了php调用mysql查询结果到变量的方法,并提供了示例代码。 ... [详细]
  • Python SQLAlchemy库的使用方法详解
    本文详细介绍了Python中使用SQLAlchemy库的方法。首先对SQLAlchemy进行了简介,包括其定义、适用的数据库类型等。然后讨论了SQLAlchemy提供的两种主要使用模式,即SQL表达式语言和ORM。针对不同的需求,给出了选择哪种模式的建议。最后,介绍了连接数据库的方法,包括创建SQLAlchemy引擎和执行SQL语句的接口。 ... [详细]
  • 解决nginx启动报错epoll_wait() reported that client prematurely closed connection的方法
    本文介绍了解决nginx启动报错epoll_wait() reported that client prematurely closed connection的方法,包括检查location配置是否正确、pass_proxy是否需要加“/”等。同时,还介绍了修改nginx的error.log日志级别为debug,以便查看详细日志信息。 ... [详细]
  • 31.项目部署
    目录1一些概念1.1项目部署1.2WSGI1.3uWSGI1.4Nginx2安装环境与迁移项目2.1项目内容2.2项目配置2.2.1DEBUG2.2.2STAT ... [详细]
author-avatar
jajajaja幸福_348
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有