I thought it might be worth mentioning some interesting changes in the manner in which the ALTER INDEX … COALESCE command works since Oracle 10g.
Basically the purpose of the COALESCE option is to reduce free space within the Leaf Blocks of an index. This is achieved by effectively performing a Full Index Scan of the leaf blocks, comparing the free space available in neighbouring blocks. In 9i, the basic method was to logically start with the left most leaf block and see if it could be coalesced or merged with the 2nd left most block. This required the sum of used space within these 2 blocks to be less than 100% of a block less the PCTFREE value. If so, the contents were merged with the contents of one block placed in the other and with the now empty leaf block removed from the index structure and placed on the index freelist.
It then looked at the 2nd leaf block (which might now be the first block if previously coalesced) and 3rd leaf blocks to see if these could be coalesced. If so they were merged and the empty block placed on the freelist.
And so on and so on until all leaf blocks had been traversed and all possible leaf blocks coalesced.
Note branch blocks are not directly merged during this process, except to be updated with modified pointer information if a leaf block coalesce had taken place. However, if enough leaf blocks are removed such that the branch block contains no more pointers to leaf blocks (or other intermediate branch blocks), it’s also removed from the index structure. However, there must always be at least one branch block from each level remaining hence the height of an index always remains the same during a coalesce operation.
Note if no leaf block had 50% or more free space, nothing would be coalesced as no two consecutive leaf blocks would have sufficient free space in which to be coalesced.
In 10g, the Coalesce operation has been modified somewhat.
An index no longer requires the sum of used space plus PCTFREE in adjacent blocks to be less than 100% of a block be effectively coalesced. For example, the free space in a block can be 25% in one leaf block and just 25% in the adjacent block (hence the combined used space alone being 150% of a block) and 10g can effectively coalesce these leaf blocks together.
This demo show how Coalesce differs between a 9i (9.2.0.7) and a 10g (10.2.0.3) database.
10g introduced the concept of being able to SHRINK an index and the Coalesce option can be viewed as now being very similar to an index Shrink command. Similar but not quite the same.
I’ll cover the similarities and differences between a Coalesce and a Shrink in the next day or two …
参考至:http://richardfoote.wordpress.com/2008/02/05/alter-index-coalesce-10g-improvements-jump-they-say/
如有错误,欢迎指正
邮箱:czmcj@163.com
相关推荐
Oracle数据库中的索引是提升查询性能...2. 重建索引有删除重建(不推荐)、`ALTER INDEX REBUILD`(推荐,尤其是在线模式)和`ALTER INDEX COALESCE`(节省空间,但不能移动索引)等方式,根据实际需求选择合适的方法。
AlterNLU-开源NLU引擎 AlterNLU是用于构建聊天机器人和AI助手的开源工具。 它为开发人员提供了在生产环境中构建助手或机器人的最小方法。 它将自然语言转换为结构化数据。 例如: 输入: {"text": "i want few ...
- `ALTER ANY INDEX`: 用户可以更改任何用户的索引结构。 - `ALTER ANY ROLE`: 能够修改已存在的角色,包括角色的权限和默认权限。 - `ALTER ANY SEQUENCE`: 可以调整其他用户拥有的序列的属性。 - `ALTER ANY ...
- `ALTER ANY INDEX`: 授予修改任意索引的权限,包括索引的定义和特性。 - `ALTER ANY ROLE`: 用户可以更改已存在的角色,如添加或删除权限。 - `ALTER ANY SEQUENCE`: 允许修改任何序列的属性,如初始值、增量等...
例如:ALTER TABLE table_name CLUSTER ON index_name; 11. SET WITHOUT CLUSTER:从表中删除最新使用的 CLUSTER 索引。 例如:ALTER TABLE table_name SET WITHOUT CLUSTER; 12. SET WITHOUT OIDS:从表中删除 ...
- `ALTER INDEX`:修改索引。 - `DROP INDEX`:删除索引。 7. 事务处理: - `BEGIN`/`START TRANSACTION`:开始一个事务。 - `COMMIT`:提交事务,保存所做的更改。 - `ROLLBACK`:回滚事务,撤销所有更改。 ...
MYSQL ALTER TABLE命令用于修改表结构,例如添加/修改/删除字段、索引、主键等等,本文章通过实例向大家介绍MYSQL ALTER TABLE语句的使用方法, ...or ADD INDEX [index_name] (index_col_name,...) or ADD
本篇文档主要介绍了两种常用的SQL语句:ALTER FUNCTION和ALTER INDEX,它们都是GBase8s对SQL ANSI/ISO标准的扩展,用于优化和调整数据库中的函数和索引。 1. ALTER FUNCTION 语句: ALTER FUNCTION 语句允许用户...
ALTER INDEX table_index REBUILD ONLINE; ``` 与常规的重建索引不同,`ONLINE`选项允许在不锁定表的情况下重建索引,从而在索引维护期间保持表的可用性。 ### 三、ALTER DATABASE命令详解 `ALTER DATABASE`命令...
- `ALTER ANY INDEX`: 允许修改任何索引,包括重建或重定义索引。 - `ALTER ANY ROLE`: 可以修改任何已存在的角色,包括添加或删除权限。 - `ALTER ANY SEQUENCE`: 允许更改任何序列的属性,如增量、最大值等。 ...
- `ALTER INDEX`:重建或重命名索引。 - `DROP INDEX`:删除不再需要的索引。 3. **表和视图管理**: - `CREATE TABLE`:创建新的表结构。 - `ALTER TABLE`:修改表的结构,如添加、删除或修改列。 - `CREATE ...
- `ALTER INDEX`:重建或重新组织索引以优化存储和查询效率。 - `DROP INDEX`:删除不必要的索引。 4. **视图和存储过程**: - `CREATE VIEW`:创建视图,提供虚拟表以简化复杂查询。 - `CREATE PROCEDURE`:...
* ALTER DATABASE 语句:用于修改数据库 * CREATE TABLE 语句:用于创建新表 * ALTER TABLE 语句:用于变更数据库表 * DROP TABLE 语句:用于删除表 * CREATE INDEX 语句:用于创建索引(搜索键) * DROP INDEX 语句...
### Oracle 10g 常用命令:数据库的备份与恢复 #### 一、基础知识与环境准备 在深入探讨 Oracle 10g 数据库的备份与恢复之前,我们需要了解一些基本概念和环境配置。 ##### 1. 连接到 Oracle 10g 数据库 - **连接...
ALTER TABLE 表名 ADD UNIQUE INDEX unq_name (字段名); ``` 这将在`字段名`上创建一个唯一索引。 13. **创建普通索引**: 创建普通索引,如`idx_example`: ```sql ALTER TABLE 表名 ADD INDEX idx_example ...
10. **存储过程(Procedure)**: - `CREATE`:允许用户创建存储过程。 - `ALTER`:允许用户修改存储过程。 - `DROP`:允许用户删除存储过程。 11. **会话(Session)**: - `CREATE`:允许用户创建会话。 - `...
在数据库管理领域,`ALTER`命令是一个非常实用且强大的工具,它允许用户修改现有表的结构,而无需重建整个表。这对于维护数据库的灵活性和适应性至关重要。根据提供的标题、描述以及部分代码示例,我们可以深入探讨`...
ALTER TABLE tablename ADD INDEX emp_name(name); ``` 这将为`tablename`表中的`name`列添加一个索引。 ### 添加主键 (Add Primary Key) 主键是表中的唯一标识符,通常用于确保数据的唯一性。例如: ```sql ALTER...
在IT领域,尤其是在数据库管理与开发中,Oracle 10g是一个非常重要的版本,它提供了丰富的功能和工具,使得数据库的管理和数据的处理变得更加高效和安全。本文将围绕“Oracle 10g创建用户和表空间”这一主题展开,...
在Oracle 10g数据库管理中,表空间(Tablespace)是重要的逻辑存储结构单元,用于组织和管理数据库中的数据文件。本文将详细介绍如何通过Oracle 10g SQL命令进行表空间的操作,包括创建、调整大小、删除等,并提供...