Common indexes in oracle

Oracle, as the industry's No.1 database, must use various indexes to improve efficiency when ensuring performance. This article aims to explore the commonly used index types in Oracle:

      B-tree index

      Bitmap index

      Hash index

      Index Organized Table

      Reverse key index

      Function-based index

      Partition index

      Bitmap connection index

B-tree index

Oracle's default index type is also the most common index type. The B-tree index can be a single-column index or a conforming index. The B-tree index contains up to 32 columns.

Oracle can traverse this binary tree from two directions. The B-tree index saves the ROWID value of each data row that is not empty on the index column. Oracle will not index rows that contain NULL values ​​on the indexed columns.

Bitmap index

Bitmap indexes are ideal for DSS and data warehouses, and they should not be used for tables in transaction processing applications. Establishing a bitmap index on a column with a low cardinality in a table with a very large amount of data can realize fast access to this type of table.

The bitmap index contains up to 30 columns.

Bitmap indexes work better for fixed-length data types than variable-length data types.

Do not use bitmap indexes in high-load OLTP.

Hash index

When using a hash index, hash clustering must be used. I have not seen how many people are using hash indexing and clustering. When a cluster or hash cluster is established, the cluster key is also defined.

Oracle can quickly use this value based on the hash function to determine the physical storage location of the row.

Hash index may be the fastest way to access data in the database, but it also has its own shortcomings. Before creating a hash cluster, you must know the number of different values ​​on the cluster key, and specify this value when creating a hash cluster.

Index Organized Table

Index-organized tables will change the storage structure of the table to a B-tree structure, sorted by the primary key of the table.

Tired and similar to cluter index, mysql seems to be more widely used.

Reverse key index

When 1234 1235 1236 is stored on the disk, it is 6321 5321 4321. The distinction is greatly improved immediately, and the efficiency is also high.

But the disadvantage of this is that it can only be used in the case of col =? And cannot be used in range queries.

Function index

create index emp_uppper_job on emp(upper(job));

In order to make the optimizer can use the function index, you need to set the parameter QUERY_REWRITE_ENABLED=true.

Partition index

Partition index simply divides an index into multiple fragments. By dividing the index into multiple physical fragments, smaller fragments can be accessed.

Both B-tree indexes and bitmap indexes can be partitioned, but hash indexes cannot be partitioned.

Partition indexes are divided into two types: local indexes and global indexes. Each type is divided into two subtypes: prefixed index and unprefixed index.

The main reason for index partitioning is to reduce the size of the index that needs to be read.

A local index is an index that uses the same partition key and range limit as the table.

Prefixed index: an index that contains partition keys and uses them as the leading column of the index.

No prefix index: refers to an index that does not use the leading column of the partition key as the leading column of the index.

 

A global index contains key values ​​from multiple table partitions in an index partition. When creating a global index, you must define the range and value of the partition key.

The global index can only be a B-tree index.

Bitmap connection index

The bitmap connection index is a bitmap index based on the connection of two tables. Using this index in the data warehouse environment can improve the query performance of the connection dimension table and the fact table.

 

Quickly rebuild the index:

alter index cust_idx rebuild  parallel tablespace cust_tblspc1 storage (pctincrease 0);

Rebuild the index online:

create index index_name on table (col) online; #Familiar?

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/David_ifx/article/details/115255552