1, the concept of index and classification

1. What is the index

A: The index database is a data table in one or more rows of a configuration will be sorted using a fast access to specific information in the index data in the table.

For example, China Mobile inside the table data may reach hundreds of millions, so that the query data index came in handy, because you can use the index to quickly retrieve the data.          

 

2, the index of classification

answer:

   <1> from the physical structure divided into two categories: clustered index and non-clustered index.

  Clustered index refers to the logical order of the index key values determines the physical order of the corresponding row in the table.

Note: A table can have only one clustered index.

For example, a student table has two columns: name and class. His order that the index corresponds to the order of the table.

His range is:

  ( 1) Range queries: using operators (e.g., between,>, <=, etc.), and returns a list of values

      ( 2) the value of continuous query: data as one month, February's data

      ( 3) returns a large result set: Note that the data retrieved through indexes typically to 20% of the total amount of the following Table, because when the index data is too large, then the system will not use the index.

      ( 4) specified in an order by clause or group by columns

 

Non-clustered index : data address table access non-clustered index recorded by the index. The logical order of the indexes of the physical storage order and the different rows in the table.

 

 

 

Note: A table can have multiple non-clustered indexes.

His case is applicable:

(1) using join or group by clause

(2) the query does not return large result sets

(3) often contain search criteria in the query (e.g., returns an exact match of the column where clause) in the.

 

   <2> minutes from the application , into  the primary key index, unique index, full-text index and combination index.

        ( 1) primary key index: When you create a primary key for a table, Sql Server will automatically create a primary key column index, and the index is a clustered index.

        ( 2) unique index: unique index may be clustered index or a non-clustered index. He asked in a unique index column is limited, does not allow duplicate key values. And the column has a unique constraint, Sql Server will automatically give him create a unique index.

        ( 3) a combination index: index column indicates the index can have a plurality. For example, student achievement table, we can test subjects ID and student ID together indexed, his usage is often more than one column together as a query.

( 4) full-text index: he is a characteristic type of token-based functional index. Under normal circumstances, create indexes for Sql Server text data.

Full-text index is mainly used for large amounts of text in a search string in the text, we know retrieve the string with T-SQL is like keywords, but in a large number of texts like the keyword efficiency is much lower than the full-text index.

 

Guess you like

Origin www.cnblogs.com/schangxiang/p/11272799.html