What is cluster in oracle




















To do this, Oracle must have an overflow area where new rows are placed if there is not room on the target block. Monitoring the overflow becomes an important task and the DBA may have to periodically reorganize the single-table index cluster table to ensure that all row orders are maintained. Feel free to ask questions on our Oracle forum. Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise.

All legitimate Oracle experts publish their Oracle qualifications. Oracle technology is changing and we strive to update our BC Oracle support information. If you find an error or have a suggestion for improving our content, we would appreciate your feedback. Just e-mail: and include the URL for the page. All rights reserved by Burleson. Also, see Oracle Row Re-sequencing For queries that access common rows with a table e.

Oracle Index Cluster Tables Unlike the hash cluster where the symbolic key is hashed to the data block address, an index cluster uses an index to maintain row sequence. Search BC Oracle Sites.

Updates to rows using Hybrid Columnar Compression cause rowids to change. By default, when a table uses Hybrid Columnar Compression, DML locks larger blocks of data compression units , which may reduce concurrency.

To avoid this issue, you can choose to enable row-level locking for a table. 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.

You specify the cluster key when creating the table cluster and when creating every table added to the table cluster. The cluster key value is the value of the cluster key columns for a particular set of rows. 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. For an analogy, suppose an HR manager has two book cases: one with boxes of employee folders and the other with boxes of department 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 and the folder for department are in another box, and so on.

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:. Less storage is required to store related table and index data because the cluster key value is not stored repeatedly for each row.

The tables frequently require a full table scan. An index cluster is a table cluster that uses an index to locate data. The cluster index is a B-tree index on the cluster key. A cluster index must be created before any rows can be inserted into clustered tables. Assume that you add rows to the employees and departments tables. The database physically stores all rows for each department from the employees and departments tables in the same data blocks.

The database stores the rows in a heap and locates them with the index. The database stores rows for employees in department 20 together, department together, and so on. If the tables are not clustered, then the database does not ensure that the related rows are stored together.

The B-tree cluster index associates the cluster key value with the database block address DBA of the block containing the data. For example, the index entry for key 20 shows the address of the block that contains data for employees in department The cluster index is separately managed, just like an index on a nonclustered table, and can exist in a separate tablespace from the table cluster. A hash cluster is like an indexed cluster, except the index key is replaced with a hash function.

No separate cluster index exists. In a hash cluster, the data is the index. With an indexed table or indexed cluster, Oracle Database locates table rows using key values stored in a separate index. To find or store a row in a hash cluster, Oracle Database applies the hash function to the cluster key value of the row.

The resulting hash value corresponds to a data block in the cluster, which the database reads or writes on behalf of the issued statement.

Hashing is an optional way of storing table data to improve the performance of data retrieval. Hash clusters may be beneficial when the following conditions are met:. For such queries, the cluster key value is hashed. The hash key value points directly to the disk area that stores the rows. You can reasonably guess the number of hash keys and the size of the data stored with each key value.

The number of hash values for the cluster depends on the hash key. The cluster key, like the key of an indexed cluster, is a single column or composite key shared by the tables in the cluster. A hash key value is an actual or possible value inserted into the cluster key column. Oracle Database uses a hash function that accepts an infinite number of hash key values as input and sorts them into a finite number of buckets. Each bucket has a unique numeric ID known as a hash value.

Each hash value maps to the database block address for the block that stores the rows corresponding to the hash key value department 10, 20, 30, and so on.

You can then load data into the hash cluster just as in the indexed cluster described in " Overview of Indexed Clusters ". In queries of a hash cluster, the database determines how to hash the key values input by the user.

The database uses the internally generated hash value to locate the block that contains the employee rows for the requested department. Figure depicts a hash cluster segment as a horizontal row of blocks. A limitation of hash clusters is the unavailability of range scans on nonindexed cluster keys see " Index Range Scan ".

Assume no separate index exists for the hash cluster created in Hash Cluster Creation. A query for departments with IDs between 20 and cannot use the hashing algorithm because it cannot hash every possible value between 20 and Because no index exists, the database must perform a full scan. A single-table hash cluster is an optimized version of a hash cluster that supports only one table at a time. A one-to-one mapping exists between hash keys and rows.

A single-table hash cluster can be beneficial when users require rapid access to a table by primary key. A sorted hash cluster stores the rows corresponding to each value of the hash function in such a way that the database can efficiently return them in sorted order. The database performs the optimized sort internally. For applications that always consume data in sorted order, this technique can mean faster retrieval of data.

The database computes a storage space value based on the following formula:. Thus, if the block size is bytes in the example shown in Hash Cluster Creation , then the database allocates at least blocks to the hash cluster. Oracle Database does not limit the number of hash key values that you can insert into the cluster. However, the efficiency of the hash cluster retrieval diminishes when the number of hash values exceeds the number of hash keys.

To illustrate the retrieval issues, assume that block in Figure is completely full with rows for department Hashing multiple input values to the same output value is called a hash collision. When users insert rows into the cluster for department 43, the database cannot store these rows in block , which is full. The database links block to a new overflow block, say block , and stores the inserted rows in the new block. Both block and are now eligible to store data for either department.

An attribute-clustered table is a heap-organized table that stores data in close proximity on disk based on user-specified clustering directives. The directives specify columns in single or multiple tables. For example, if queries of sh.

It is ignored for conventional DML. Advantages of Attribute-Clustered Tables. Join Attribute Clustered Tables. Attribute-Clustered Tables with Linear Ordering. Attribute-Clustered Tables with Interleaved Ordering.

In star schemas, most queries qualify dimension tables and not fact tables, so clustering by fact table columns is not effective.

Oracle Database supports clustering on columns in dimension tables. In OLTP applications for queries that qualify a prefix and use attribute clustering with linear order. Attribute clustering can improve data compression, and in this way indirectly improve table scan costs.

When the same values are close to each other on disk, the database can more easily compress them. Oracle Database Data Warehousing Guide for more advantages of attribute-clustered tables.

Attribute clustering that is based on joined columns is called join attribute clustering. In contrast with table clusters, join attribute clustered tables do not store data from a group of tables in the same database blocks. For example, consider an attribute-clustered table, sales , joined with a dimension table, products.

The sales table contains only rows from the sales table, but the ordering of the rows is based on the values of columns joined from products table. In contrast, if sales and products were in a standard table cluster, the data blocks would contain rows from both tables. Oracle Database Data Warehousing Guide to learn more about join attribute clustering.

A zone is a set of contiguous data blocks that stores the minimum and maximum values of relevant columns. When a SQL statement contains predicates on columns stored in a zone, the database compares the predicate values to the minimum and maximum stored in the zone to determine which zones to read during SQL execution. A zone map is an independent access structure that divides data blocks into zones. Oracle Database implements each zone map as a type of materialized view.

The zone map correlates minimum and maximum values of columns with consecutive data blocks in the attribute-clustered table. You can create attribute-clustered tables that do not use zone maps. You can also create zone maps without attribute-clustered tables. For example, you can create a zone map on a table whose rows are naturally ordered on a set of columns, such as a stock trade table whose trades are ordered by time.

You execute DDL statements to create, drop, and maintain zone maps. Oracle Database Data Warehousing Guide to learn more about zone maps. For a loose analogy of zone maps, consider a sales manager who uses a bookcase of pigeonholes, which are analogous to data blocks.

Each pigeonhole has receipts rows describing shirts sold to a customer, ordered by ship date. In this analogy, a zone map is like a stack of index cards. Each card corresponds to a "zone" contiguous range of pigeonholes, such as pigeonholes For each zone, the card lists the minimum and maximum ship dates for the receipts stored in the zone. When someone wants to know which shirts shipped on a certain date, the manager flips the cards until she comes to the date range that contains the requested date, notes the pigeonhole zone, and then searches only pigeonholes in this zone for the requested receipts.

In this way, the manager avoids searching every pigeonhole in the bookcase for the receipts. This example illustrates how a zone map can prune data in a query whose predicate contains a constant. The table lineitem contains 4 data blocks with 2 rows per block. Table shows the 8 rows of the table. Each zone contains 2 blocks and stores the minimum and maximum of the orderkey , shipdate , and receiptdate columns.

Table shows the zone map. When you execute the following query, the database can read the zone map and then scan only blocks 1 and 2 because the date falls between the minimum and maximum dates:. Oracle Database Data Warehousing Guide to learn how to use zone maps.

A linear ordering scheme for a table divides rows into ranges based on user-specified attributes in a specific order. Oracle Database supports linear ordering on single or multiple tables that are connected through a primary-foreign key relationship. Oracle Database Data Warehousing Guide to learn how to cluster tables using linear ordering. Interleaved ordering uses a technique that is similar to a Z-order.

Interleaved ordering is useful for dimensional hierarchies in a data warehouse. As with attribute-clustered tables with linear ordering, Oracle Database supports interleaved ordering on single or multiple tables that are connected through a primary-foreign key relationship. Columns in tables other than the attribute-clustered table must be linked by foreign key and joined to the attribute-clustered table. Large data warehouses frequently organize data in a star schema. A dimension table uses a parent-child hierarchy and is connected to a fact table by a foreign key see " Overview of Dimensions ".

Clustering a fact table by interleaved order enables the database to use a special function to skip values in dimension columns during table scans. Suppose your data warehouse contains a sales fact table and its two dimension tables: customers and products.

You can use interleaved ordering for the sales table as shown in the partial statement in the following example:. Suppose an application queries the sales , products , and customers tables in a join. The query specifies the customers. During the scan of the sales table, the database can consult the zone map and access only the rowids in this zone.

Oracle Database Data Warehousing Guide to learn how to cluster tables using interleaved ordering. A temporary table holds data that exists only for the duration of a transaction or session. Data in a temporary table is private to the session, which means that each session can only see and modify its own data.

These indexes are also temporary. The data in the index has the same session or transaction scope as the data in the temporary table. You can also create a view or trigger on a temporary table.

Like permanent tables, temporary tables are persistent objects that are statically defined in the data dictionary. Temporary segments are allocated when a session first inserts data. Until data is loaded in a session, the temporary table appears empty.

For transaction-specific temporary tables, the database deallocates temporary segments at the end of the transaction. For session-specific temporary tables, the database deallocates temporary segments at the end of the session. An external table accesses data in external sources as if this data were in a table in the database. External tables are useful for querying flat files.

For example, a SQL-based application may need to access records in a text file. The records are in the following form:. You could create an external table, copy the file to the location specified in the external table definition, and use SQL to query the records in the text file. External tables are also valuable for performing ETL tasks common in data warehouse environments.

For example, external tables enable the pipelining of the data loading phase with the transformation phase, eliminating the need to stage data inside the database in preparation for further processing inside the database. Internally, creating an external table means creating metadata in the data dictionary. Unlike an ordinary table, an external table does not describe data stored in the database, nor does it describe how data is stored externally. Rather, external table metadata describes how the external table layer must present data to the database.

The external table definition describes the column types. This definition is like a view that enables SQL to query external data without loading it into the database. The second part of the statement maps the external data to the columns. Restrictions for external tables include no support for indexed columns, virtual columns, and column objects.

An access driver is an API that interprets the external data for the database. The access driver runs inside the database, which uses the driver to read the data in the external table. The access driver and the external table layer are responsible for performing the transformations required on the data in the data file so that it matches the external table definition.

Figure represents how external data is accessed. For both drivers, the external files are not Oracle data files.

This operation involves reading data from the database and inserting the data into an external table, represented by one or more external files. After external files are created, the database cannot update or append data to them. The driver also enables you to load external data, which involves reading an external table and loading its data into a database. Oracle Database Administrator's Guide to learn about managing external tables, external connections, and directory objects.

Oracle Database Utilities to learn about external tables. An Oracle object type is a user-defined type with a name, attributes, and methods. An object table is a special kind of table in which each row represents an object. Object types make it possible to model real-world entities such as customers and purchase orders as objects in the database. An object type defines a logical structure, but does not create storage.

Like a relational column, an object table can contain rows of just one kind of thing, namely, object instances of the same declared type as the table. By default, every row object in an object table has an associated logical object identifier OID that uniquely identifies it in an object table.

The OID column of an object table is a hidden column. Introduction to Schema Objects A database schema is a logical container for data structures, called schema objects. See Also: " Overview of Database Security " to learn more about users and privileges. The principal types of schema objects are: Tables A table stores data in rows. Indexes Indexes are schema objects that contain an entry for each indexed row of the table or table cluster and provide direct, fast access to rows.

Partitions Partitions are pieces of large tables and indexes. Views Views are customized presentations of data in one or more tables or other views. Sequences A sequence is a user-created object that can be shared by multiple users to generate integers. Dimensions A dimension defines a parent-child relationship between pairs of column sets, where all the columns of a column set must come from the same table.

Synonyms A synonym is an alias for another schema object. Schema Object Storage Some schema objects store data in a type of logical storage structure called a segment. The padding is used for this test to increase the size of the rows, and therefore the number of blocks required to store them.

If we pull back all the records for a single customer, we can see it's taking consistent gets to return the data. We also display the clustering factor of the new index. We run the query again, but we don't see a dramatic improvement in the number of consistent gets, because we have not used the index.

The data for customer "1" is spread throughout the table, and the database determined it was still going to have to hit a lot of blocks to get it all, whether using the index or not, so it chose not to use it. This is a classic case of the index having a high cluster factor, so the optimizer has chosen not to use it in this scenario.



0コメント

  • 1000 / 1000