什么是Table Clusters?

Overview of Table Clusters

A table cluster is a group of tables that share common columns and
store related data in the same blocks. When tables are clustered, a
single data block can contain rows from multiple tables. For example,
a block can store rows from both the employees and departments tables
rather than from only a single table.

一个数据块可存储来自多个表的共有的行。

The cluster key is the column or columns that the clustered tables
have in common. For example, the employees and departments tables
share the department_id column. You specify the cluster key when
creating the table cluster and when creating every table added to the
table cluster.

cluster key表示clustered table都有的列。例如employees和departments表都有department_id列。

The cluster key value is the value of the cluster key columns for a
particular set of rows. All data that contains the same cluster key
value, such as department_id=20, is physically stored together. Each
cluster key value is stored only once in the cluster and the cluster
index, no matter how many rows of different tables contain the value.

cluster key value表示cluster key上一组特殊的行。所有数据都包含相同的key value,例如department_id=20。只在cluster table和cluster index存储一次。

For an analogy, suppose an HR manager has two book cases: one with
boxes of employees folders and the other with boxes of departments
folders. Users often ask for the folders for all employees in a
particular department. To make retrieval easier, the manager rearranges all the boxes in a single book case. She divides the boxes by department ID. Thus, all folders for employees in department 20 and the folder for department 20 itself are in one box; the folders for employees in department 100 and the folder for department 100 are in a different box, and so on.

举了个例子。

You can consider clustering tables when they are primarily queried (but not modified) and records from the tables are frequently queried together or joined. Because table clusters store related rows of different tables in the same data blocks, properly used table clusters offer the following benefits over nonclustered tables:
* Disk I/O is reduced for joins of clustered tables.
* Access time improves for joins of clustered tables.
* Less storage is required to store related table and index data because the cluster key value is not stored repeatedly for each row.

cluster table的好处
因为相关行都存储在同一个数据块上,这对频繁在一起查询或join的表们有好处:
* join的时候,减少磁盘IO
* join的时候,提升访问时间
* 不需要那么多存储,因为cluster key value只有一个

Typically, clustering tables is not appropriate in the following
situations:
The tables are frequently updated.
The tables frequently require a full table scan.
The tables require truncating.

不适用的场景:
* 需要频繁更新的表
* 需要频繁全表扫描的表
* 有truncate需求的表

See Also:
Oracle Database Performance Tuning Guide for guidelines on when to use table clusters

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值