How Extents Are Allocated When Extents Are Deallocated【每日一译]--2012-10-23

Oracle uses different algorithms to allocate extents, depending on whether they are

locally managed or dictionary managed.

ORACLE使用不同的算法去分配区块,这取决于它们是否是本地管理还是数据字典管理。

With locally managed tablespaces, Oracle looks for free space to allocate to a new
extent by first determining a candidate datafile in the tablespace and then searching
the datafile’s bitmap for the required number of adjacent free blocks. If that datafile

does not have enough adjacent free space, then Oracle looks in another datafile.

对于本地管理的表空间,ORACLE查找空闲空间去分配给一个新的区块通过首先确定一个选定

文件然后查找数据文件中的位图对于相邻空闲块的要求数。如果数据文件没有足够的相邻空闲

空间,那么ORACLE在另外一个文件中去查找。

Note: Oracle strongly recommends that you use locally managed
tablespaces

备注:ORACLE强烈建议你使用本地管理表空间方式

When Extents Are Deallocated

区块什么时候回收呢?
The Oracle Database provides a Segment Advisor that helps you determine whether
an object has space available for reclamation based on the level of space fragmentation
within the object.

ORACLE提供了一个段顾问帮你确认对象是否拥有可回收的空间在对象的空间碎片级别上。

In general, the extents of a segment do not return to the tablespace until you drop the
schema object whose data is stored in the segment (using a DROP TABLE or DROP
CLUSTER statement). Exceptions to this include the following:

简而言之,段的区块不能回收对于表空间直到你DROP那个用户的对象,他的数据存储在段中(

使用DROP TABLE或DROP CLUSTER STATEMENT)。除了包含下面的几种情况:

■ The owner of a table or cluster, or a user with the DELETE ANY privilege, can
truncate the table or cluster with a TRUNCATE...DROP STORAGE statement.

表或者聚簇表的用户,或者是一个用户拥有删除任何权限(delete any)可以truncate表或者

是聚簇表用一个truncate...drop storage的语句。

■ A database administrator (DBA) can deallocate unused extents using the following
SQL syntax:
ALTER TABLE table_name DEALLOCATE UNUSED;

一个数据库管理员可以回收未使用的区块使用如下SQL语法:

alter table table_name deallocate unused;

■ Periodically, Oracle deallocates one or more extents of a rollback segment if it has
the OPTIMAL size specified.

周期性地,ORACLE分配一个或者更多的回滚段的区块如它指定了最佳的大小.
When extents are freed, Oracle modifies the bitmap in the datafile (for locally
managed tablespaces) or updates the data dictionary (for dictionary managed

tablespaces) to reflect the regained extents as available space. Any data in the blocks of

freed extents becomes inaccessible.

当区块空闲时候 ,ORACLE修改在数据文件中的位图(针对本地管理表空间)或者更新

数据字典(针对数据字典管理表空间)反应重新收回的 区块作为可用的空间。任何

空闲区块中的数据变得不可访问.


Extents in Nonclustered Tables
As long as a nonclustered table exists or until you truncate the table, any data block
allocated to its data segment remains allocated for the table. Oracle inserts new rows
into a block if there is enough room. Even if you delete all rows of a table, Oracle does
not reclaim the data blocks for use by other objects in the tablespace.

EXTENTS在非聚簇表情况

只要存在一个非聚簇表或者直到你TRUNCATE表时,对于这个表的任何数据块分配

对于它的数据段仍保留分配。一个块中如果有足够空间ORACLE插入新行到这个数据块。

尽管你删除了表中的所有行,ORACLE并不回收被其它对象使用的数据块在表空间中.


After you drop a nonclustered table, this space can be reclaimed when other extents
require free space. Oracle reclaims all the extents of the table’s data and index
segments for the tablespaces that they were in and makes the extents available for
other schema objects in the same tablespace.

当你DROP一个非聚簇表时,当其它区块要求空闲空间时候可以被回收。ORACLE

回收表数据和它们所在的索引段表空间的所有区块,这样对同一个表空间的其它用户

的对象来说是可用的。


In dictionary managed tablespaces, when a segment requires an extent larger than the
available extents, Oracle identifies and combines contiguous reclaimed extents to form
a larger one. This is called coalescing extents. Coalescing extents is not necessary in
locally managed tablespaces, because all contiguous free space is available for
allocation to a new extent regardless of whether it was reclaimed from one or more
extents.

在数据字典管理表空间,ORACLE检测并且合并相邻可回收的区块成一个更大的区块。

这个叫做合并区块。在本地管理表空间中合并区块是不需要的。因为所有相邻空闲空间

可用于分配给一个新的区块不管它否从一个或多个区块中回收.


Extents in Clustered Tables
Clustered tables store information in the data segment created for the cluster.
Therefore, if you drop one table in a cluster, the data segment remains for the other
tables in the cluster, and no extents are deallocated. You can also truncate clusters
(except for hash clusters) to free extents.

EXTENTS在聚簇表的情况

聚簇表存储信息在数据段中创建对于聚簇来说。所以在一个聚簇中DROP一个表,在数据段中

保留了聚簇中的其它表,并且没有区块是被回收的。你也可以TRUNCATE聚簇(除了HASH聚簇)

去释放区块.

Extents in Materialized Views and Their Logs
Oracle deallocates the extents of materialized views and materialized view logs in the
same manner as for tables and clusters.

区块在物化视图和它们的日志

ORACLE回收物化视图和物化视图日志区块用同一种方法对于表和聚簇表来说.

Extents in Indexes
All extents allocated to an index segment remain allocated as long as the index exists.
When you drop the index or associated table or cluster, Oracle reclaims the extents for
other uses within the tablespace.

区块在索引时候

所有区块分配给一个索引段保留分配当索引存在时。

当你DROP索引或者它的相关表或聚簇表时,ORACLE回收区块供其它使用在表空间中。

Extents in Temporary Segments
When Oracle completes the execution of a statement requiring a temporary segment,
Oracle automatically drops the temporary segment and returns the extents allocated
for that segment to the associated tablespace. A single sort allocates its own temporary
segment in a temporary tablespace of the user issuing the statement and then returns
the extents to the tablespaces.

在临时段的区块

当ORACLE完成要求临时段执行的语句时,ORACLE自动DROP临时段并且反回临时段的分配

对于这个段相关的表空间。一个单独排序分配它自己的输入语句的临时表空间的临时段然后

返回表空间的区块。

Multiple sorts, however, can use sort segments in temporary tablespaces designated
exclusively for sorts. These sort segments are allocated only once for the instance, and
they are not returned after the sort, but remain available for other multiple sorts.

多样排序,可以使用专门设计给排序的临时表空间的临时段。这些排序段对于实例来说

只分配一次,并且它们在排完序后不需要返回空间,但对于其它多样排序保留可用.

A temporary segment in a temporary table contains data for multiple statements of a
single transaction or session. Oracle drops the temporary segment at the end of the
transaction or session, returning the extents allocated for that segment to the
associated tablespace.

一个临时段在一个临时表中包含数据对于一个单独事务或者会话的多个语句。ORACLE

在事务或会话结束时候DROP临时段,返回分配的区块对于相关表空间的段。

Extents in Rollback Segments
Oracle periodically checks the rollback segments of the database to see if they have
grown larger than their optimal size. If a rollback segment is larger than is optimal
(that is, it has too many extents), then Oracle automatically deallocates one or more
extents from the rollback segment.

在回滚段中的区块

oracle周期性核对数据库的回滚段去查看它们是否增长大于最佳大小。如果一个回滚段大于

最佳大小(也就是它有太多的区块),那么ORACLE自动回收一个或多个区块从回滚段中。



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值