Manage Index 1 - Principle Introduction

Introduction
Indexes are data objects used to speed up data access. Reasonable use of indexes can greatly reduce the number of I/Os, thereby improving data access performance.

Create an index
1. Single-column index
A single-column index is an index based on a single column, such as:
create index index name on table name (column name)

SQL> create index nameIndex on customer(name);

the index has been created.


2. Composite Index
Composite index is based on two or more columns of the index. There can be multiple indexes on the same table, but the combination of columns must be different, for example:

create index emp_idx1 on emp (ename,job);
//The above is to first check the index ename and then check the index job
create index emp_idx1 on emp (job,ename);
//The above is to check the index job first and then check the index ename

. Therefore, when building a composite index, the index that can filter out multiple data should be placed at the back, because oracle is queried from the back to the front. , so this design can improve the efficiency of the query.


Principles of use
1. It makes sense to build an index on a large table
2. Build an index on a column that is often referenced in a where clause or a join condition
3. The level of the index should not exceed 4 levels



Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327060574&siteId=291194637