SQL Server review-Index

Source: Internet
Author: User

Index cost

1. Added, changed, and deleted indexes are maintained.

2. Indexes occupy a certain amount of physical space

 

Indexing principles

1. The primary key must be indexed

2. Foreign keys must be indexed

3. It is best to create an index for frequently queried data.

A. You can use index sorting to accelerate the query time for range data.

B. Create an index in the set of where clauses

4. Do not create indexes for columns that are rarely involved in queries and columns with multiple duplicate values.

5. Do not create indexes for columns with large or small data volumes.

 

Index category

1. Clustered index (physical sorting) (only one)

2. Non-clustered index (no physical sorting) (249)

3. Unique index (unique constraint on data)

 

Index Analysis

1. showplan_all (display query plan)

Demo: Set showplan_all on

2. Statistics io (retrieve disk activity volume)

Demo: Set statistics Io on

 

Index Maintenance

Over time, due to a series of operations such as addition, deletion, and modification, data becomes disordered. Index maintenance required

1. Statistics Update

Update statistics class pk_class

2. Scan table information

DBCC showcontig (class, pk_class)

Note: The scan density of 100% is an ideal value. If the scan density is too low, the table fragments need to be cleared.

3. Fragment

DBCC indexdefrag (sukinshow, class, pk_class)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.