Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005
CHAPTER 3 ■ FILES 93 (data from more than one table may be stored on the same block). The row directory contains information describing the rows that are to be found on the block. This is an array of pointers to where the rows are to be found in the data portion of the block. These three pieces of the block are collectively known as the block overhead, which is space used on the block that is not available for your data, but rather is used by Oracle to manage the block itself. The remaining two pieces of the block are straightforward: there will possibly be free space on a block, and then there will generally be used space that is currently storing data. Now that you have a cursory understanding of segments, which consist of extents, which consist of blocks, let’s take a closer look at tablespaces and then at exactly how files fit into the big picture. Tablespaces As noted earlier, a tablespace is a container—it holds segments. Each and every segment belongs to exactly one tablespace. A tablespace may have many segments within it. All of the extents for a given segment will be found in the tablespace associated with that segment. Segments never cross tablespace boundaries. A tablespace itself has one or more data files associated with it. An extent for any given segment in a tablespace will be contained entirely within one data file. However, a segment may have extents from many different data files. Graphically, a tablespace might look like Figure 3-3. Figure 3-3. A tablespace containing two data files, three segments, and four extents Figure 3-3 shows a tablespace named USER_DATA. It consists of two data files, user_data01 and user_data02. It has three segments allocated it: T1, T2, and I1 (probably two tables and an index). The tablespace has four extents allocated in it, and each extent is depicted as a logically contiguous set of database blocks. Segment T1 consists of two extents, one extent in each file. Segments T2 and I1 each have one extent depicted. If we need more space in this tablespace, we could either resize the data files already allocated to the tablespace or we could add a third data file to it. Tablespaces are a logical storage container in Oracle. As developers, we will create segments in tablespaces. We will never get down to the raw “file level”—we do not specify that we want our extents to be allocated in a specific file (we can, but we do not in general). Rather, we create objects in tablespaces, and Oracle takes care of the rest. If at some point in the future, the DBA decides to move our data files around on disk to more evenly distribute I/O, that is OK with us. It will not affect our processing at all.
94 CHAPTER 3 ■ FILES Storage Hierarchy Summary In summary, the hierarchy of storage in Oracle is as follows: 1. A database is made up of one or more tablespaces. 2. A tablespace is made up of one or more data files. These files might be cooked files in a file system, raw partitions, ASM managed database files, or a file on a clustered file system. A tablespace contains segments. 3. A segment (TABLE, INDEX, and so on) is made up of one or more extents. A segment exists in a tablespace, but may have data in many data files within that tablespace. 4. An extent is a logically contiguous set of blocks on disk. An extent is in a single tablespace and, furthermore, is always in a single file within that tablespace. 5. A block is the smallest unit of allocation in the database. A block is the smallest unit of I/O used by a database. Dictionary-Managed and Locally-Managed Tablespaces Before we move on, we will look at one more topic related to tablespaces: how extents are managed in a tablespace. Prior to Oracle 8.1.5, there was only one method to manage the allocation of extents within a tablespace: a dictionary-managed tablespace. That is, the space within a tablespace was managed in data dictionary tables, in much the same way you would manage accounting data, perhaps with a DEBIT and CREDIT table. On the debit side, we have all of the extents allocated to objects. On the credit side, we have all of the free extents available for use. When an object needed another extent, it would ask the system to get one. Oracle would then go to its data dictionary tables, run some queries, find the space (or not), and then update a row in one table (or remove it all together) and insert a row into another. Oracle managed space in very much the same way you will write your applications: by modifying data and moving it around. This SQL, executed on your behalf in the background to get the additional space, is referred to as recursive SQL. Your SQL INSERT statement caused other recursive SQL to be executed to get more space. This recursive SQL can be quite expensive if it is done frequently. Such updates to the data dictionary must be serialized; they cannot be done simultaneously. They are something to be avoided. In earlier releases of Oracle, we would see this space management issue—this recursive SQL overhead—most often occurring in temporary tablespaces (this was before the introduction of “real” temporary tablespaces created via the CREATE TEMPORARY TABLESPACE command). Space would frequently be allocated (we would have to delete from one dictionary table and insert into another) and de-allocated (we would put the rows we just moved back where they were initially). These operations would tend to serialize, dramatically decreasing concurrency and increasing wait times. In version 7.3, Oracle introduced the concept of a true temporary tablespace, a new tablespace type dedicated to just storing temporary data, to help alleviate this issue. Prior to this special tablespace type, temporary data was managed in the same tablespaces as persistent data and treated in much the same way as permanent data was. A temporary tablespace was one in which you could create no permanent objects of your own. This was fundamentally the only difference; the space was still managed in the data
- Page 88 and 89: CHAPTER 1 ■ DEVELOPING SUCCESSFUL
- Page 90 and 91: CHAPTER 1 ■ DEVELOPING SUCCESSFUL
- Page 92: CHAPTER 1 ■ DEVELOPING SUCCESSFUL
- Page 95 and 96: 50 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 97 and 98: 52 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 99 and 100: 54 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 101 and 102: 56 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 103 and 104: 58 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 105 and 106: 60 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 107 and 108: 62 CHAPTER 2 ■ ARCHITECTURE OVERV
- Page 110 and 111: CHAPTER 3 ■ ■ ■ Files In this
- Page 112 and 113: CHAPTER 3 ■ FILES 67 Without a pa
- Page 114 and 115: CHAPTER 3 ■ FILES 69 and even dat
- Page 116 and 117: CHAPTER 3 ■ FILES 71 all operatio
- Page 118 and 119: CHAPTER 3 ■ FILES 73 *.cluster_da
- Page 120 and 121: CHAPTER 3 ■ FILES 75 ops$tkyte@OR
- Page 122 and 123: CHAPTER 3 ■ FILES 77 • To maint
- Page 124 and 125: CHAPTER 3 ■ FILES 79 • Resource
- Page 126 and 127: CHAPTER 3 ■ FILES 81 3 l_dummy nu
- Page 128 and 129: CHAPTER 3 ■ FILES 83 Trace Files
- Page 130 and 131: CHAPTER 3 ■ FILES 85 _qerixAlloca
- Page 132 and 133: CHAPTER 3 ■ FILES 87 6 ( 7 TYPE O
- Page 134 and 135: CHAPTER 3 ■ FILES 89 A Brief Revi
- Page 136 and 137: CHAPTER 3 ■ FILES 91 Redundant Ar
- Page 140 and 141: CHAPTER 3 ■ FILES 95 dictionary t
- Page 142 and 143: CHAPTER 3 ■ FILES 97 ■Note df i
- Page 144 and 145: CHAPTER 3 ■ FILES 99 “accidenta
- Page 146 and 147: CHAPTER 3 ■ FILES 101 So, at the
- Page 148 and 149: CHAPTER 3 ■ FILES 103 Password Fi
- Page 150 and 151: CHAPTER 3 ■ FILES 105 USER is "SY
- Page 152 and 153: CHAPTER 3 ■ FILES 107 Flashback L
- Page 154 and 155: CHAPTER 3 ■ FILES 109 of the requ
- Page 156 and 157: CHAPTER 3 ■ FILES 111 IMPDP, howe
- Page 158 and 159: CHAPTER 3 ■ FILES 113 tkyte@ORA10
- Page 160 and 161: CHAPTER 4 ■ ■ ■ Memory Struct
- Page 162 and 163: CHAPTER 4 ■ MEMORY STRUCTURES 117
- Page 164 and 165: CHAPTER 4 ■ MEMORY STRUCTURES 119
- Page 166 and 167: CHAPTER 4 ■ MEMORY STRUCTURES 121
- Page 168 and 169: CHAPTER 4 ■ MEMORY STRUCTURES 123
- Page 170 and 171: CHAPTER 4 ■ MEMORY STRUCTURES 125
- Page 172 and 173: CHAPTER 4 ■ MEMORY STRUCTURES 127
- Page 174 and 175: CHAPTER 4 ■ MEMORY STRUCTURES 129
- Page 176 and 177: CHAPTER 4 ■ MEMORY STRUCTURES 131
- Page 178 and 179: CHAPTER 4 ■ MEMORY STRUCTURES 133
- Page 180 and 181: CHAPTER 4 ■ MEMORY STRUCTURES 135
- Page 182 and 183: CHAPTER 4 ■ MEMORY STRUCTURES 137
- Page 184 and 185: CHAPTER 4 ■ MEMORY STRUCTURES 139
- Page 186 and 187: CHAPTER 4 ■ MEMORY STRUCTURES 141
94<br />
CHAPTER 3 ■ FILES<br />
Storage Hierarchy Summary<br />
In summary, the hierarchy of storage in <strong>Oracle</strong> is as follows:<br />
1. A database is made up of one or more tablespaces.<br />
2. A tablespace is made up of one or more data files. These files might be cooked files in<br />
a file system, raw partitions, ASM managed database files, or a file on a clustered file<br />
system. A tablespace contains segments.<br />
3. A segment (TABLE, INDEX, <strong>and</strong> so on) is made up of one or more extents. A segment<br />
exists in a tablespace, but may have data in many data files within that tablespace.<br />
4. An extent is a logically contiguous set of blocks on disk. An extent is in a single tablespace<br />
<strong>and</strong>, furthermore, is always in a single file within that tablespace.<br />
5. A block is the smallest unit of allocation in the database. A block is the smallest unit of<br />
I/O used by a database.<br />
Dictionary-Managed <strong>and</strong> Locally-Managed Tablespaces<br />
Before we move on, we will look at one more topic related to tablespaces: how extents are<br />
managed in a tablespace. Prior to <strong>Oracle</strong> 8.1.5, there was only one method to manage the allocation<br />
of extents within a tablespace: a dictionary-managed tablespace. That is, the space<br />
within a tablespace was managed in data dictionary tables, in much the same way you would<br />
manage accounting data, perhaps with a DEBIT <strong>and</strong> CREDIT table. On the debit side, we have all<br />
of the extents allocated to objects. On the credit side, we have all of the free extents available<br />
for use. When an object needed another extent, it would ask the system to get one. <strong>Oracle</strong><br />
would then go to its data dictionary tables, run some queries, find the space (or not), <strong>and</strong> then<br />
update a row in one table (or remove it all together) <strong>and</strong> insert a row into another. <strong>Oracle</strong><br />
managed space in very much the same way you will write your applications: by modifying<br />
data <strong>and</strong> moving it around.<br />
This SQL, executed on your behalf in the background to get the additional space, is<br />
referred to as recursive SQL. Your SQL INSERT statement caused other recursive SQL to be executed<br />
to get more space. This recursive SQL can be quite expensive if it is done frequently.<br />
Such updates to the data dictionary must be serialized; they cannot be done simultaneously.<br />
They are something to be avoided.<br />
In earlier releases of <strong>Oracle</strong>, we would see this space management issue—this recursive<br />
SQL overhead—most often occurring in temporary tablespaces (this was before the introduction<br />
of “real” temporary tablespaces created via the CREATE TEMPORARY TABLESPACE comm<strong>and</strong>).<br />
Space would frequently be allocated (we would have to delete from one dictionary table <strong>and</strong><br />
insert into another) <strong>and</strong> de-allocated (we would put the rows we just moved back where they<br />
were initially). These operations would tend to serialize, dramatically decreasing concurrency<br />
<strong>and</strong> increasing wait times. In version 7.3, <strong>Oracle</strong> introduced the concept of a true temporary<br />
tablespace, a new tablespace type dedicated to just storing temporary data, to help alleviate<br />
this issue. Prior to this special tablespace type, temporary data was managed in the same<br />
tablespaces as persistent data <strong>and</strong> treated in much the same way as permanent data was.<br />
A temporary tablespace was one in which you could create no permanent objects of your<br />
own. This was fundamentally the only difference; the space was still managed in the data