Home Backend Development PHP Tutorial Tips for optimizing SQL Server indexes_PHP tutorial

Tips for optimizing SQL Server indexes_PHP tutorial

Jul 13, 2016 pm 05:01 PM
server sql optimization Can and Small Skill Detection of index Adjustment

There are several tools in SQL Server that allow you to detect, tune, and optimize SQL Server performance. In this article, I will explain how to use SQL Server tools to optimize the use of database indexes. This article also involves general knowledge about indexes.
Common sense about indexes

The biggest factor affecting database performance is the index. Because of the complexity of the issue, I can only briefly touch on it, but there are several good books on this subject that you can read. I will only discuss two types of SQL Server indexes here, namely clustered indexes and nonclustered indexes. When considering what type of index to create, you should consider the data type and the column that holds the data. Likewise, you must also consider the types of queries your database is likely to use and which types of queries are used most frequently.
Type of index
If the column stores highly related data and is often accessed sequentially, it is best to use a clustered index. This is because if you use a clustered index, SQL Server will physically sort it in ascending order (default) Or rearrange the data columns in descending order so that you can quickly find the queried data. Similarly, when the search is controlled within a certain range, it is best to use clustered indexes for these columns. This is because due to the physical rearrangement of the data, there is only one clustered index on each table.
Contrary to the above situation, if the columns contain less relevant data, you can use nonculstered indexes. You can use up to 249 nonclustered indexes on a table - although I can't imagine a practical application using that many indexes.
When a table uses primary keys, by default SQL Server will automatically create a unique cluster index for the column(s) containing the key. Obviously, establishing unique indexes on these column(s) means the uniqueness of the primary key. When establishing a foreign key relationship, it is a good idea to create a nonclustered index on the foreign key cloumn if you plan to use it frequently. If the table has a clustered index, then it uses a linked list to maintain the relationship between data pages. Conversely, if the table does not have a clustered index, SQL Server will save the data pages in a stack.
Data page
When the index is established, SQL Server creates a data page (datapage), which is a pointer used to speed up search. When an index is created, its corresponding fill factor is set. The fill factor is set to indicate the percentage of data pages in the index. Over time, database updates consume existing free space, which causes pages to be split. The consequence of page splits is that the performance of the index is reduced, and therefore queries using the index result in fragmented data storage. When an index is created, the index's fill factor is set, so the fill factor cannot be dynamically maintained.
In order to update the fill factor in the data page, we can stop the old index, rebuild the index, and reset the fill factor (note: this will affect the operation of the current database, please use it with caution on important occasions). DBCC INDEXDEFRAG and DBCC DBREINDEX are two commands that clear clustered and nonculstered index fragments. INDEXDEFRAG is an online operation (that is, it does not block other table operations, such as queries), while DBREINDEX physically rebuilds the index. In most cases, rebuilding the index can better eliminate fragmentation, but this advantage comes at the expense of blocking other actions currently occurring on the table where the index is located. When a large fragmented index occurs, INDEXDEFRAG will take a longer time because the command runs based on small transactional blocks.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631135.htmlTechArticleThere are several tools in SQL Server that allow you to detect, adjust and optimize SQL Server performance. In this article, I will explain how to use SQL Server tools to optimize the use of database indexes. This article...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between HQL and SQL in Hibernate framework? What is the difference between HQL and SQL in Hibernate framework? Apr 17, 2024 pm 02:57 PM

HQL and SQL are compared in the Hibernate framework: HQL (1. Object-oriented syntax, 2. Database-independent queries, 3. Type safety), while SQL directly operates the database (1. Database-independent standards, 2. Complex executable queries and data manipulation).

Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Win11 Tips Sharing: Skip Microsoft Account Login with One Trick Mar 27, 2024 pm 02:57 PM

Win11 Tips Sharing: One trick to skip Microsoft account login Windows 11 is the latest operating system launched by Microsoft, with a new design style and many practical functions. However, for some users, having to log in to their Microsoft account every time they boot up the system can be a bit annoying. If you are one of them, you might as well try the following tips, which will allow you to skip logging in with a Microsoft account and enter the desktop interface directly. First, we need to create a local account in the system to log in instead of a Microsoft account. The advantage of doing this is

MIT's latest masterpiece: using GPT-3.5 to solve the problem of time series anomaly detection MIT's latest masterpiece: using GPT-3.5 to solve the problem of time series anomaly detection Jun 08, 2024 pm 06:09 PM

Today I would like to introduce to you an article published by MIT last week, using GPT-3.5-turbo to solve the problem of time series anomaly detection, and initially verifying the effectiveness of LLM in time series anomaly detection. There is no finetune in the whole process, and GPT-3.5-turbo is used directly for anomaly detection. The core of this article is how to convert time series into input that can be recognized by GPT-3.5-turbo, and how to design prompts or pipelines to let LLM solve the anomaly detection task. Let me introduce this work to you in detail. Image paper title: Largelanguagemodelscanbezero-shotanomalydete

A must-have for veterans: Tips and precautions for * and & in C language A must-have for veterans: Tips and precautions for * and & in C language Apr 04, 2024 am 08:21 AM

In C language, it represents a pointer, which stores the address of other variables; & represents the address operator, which returns the memory address of a variable. Tips for using pointers include defining pointers, dereferencing pointers, and ensuring that pointers point to valid addresses; tips for using address operators & include obtaining variable addresses, and returning the address of the first element of the array when obtaining the address of an array element. A practical example demonstrating the use of pointer and address operators to reverse a string.

Improved detection algorithm: for target detection in high-resolution optical remote sensing images Improved detection algorithm: for target detection in high-resolution optical remote sensing images Jun 06, 2024 pm 12:33 PM

01 Outlook Summary Currently, it is difficult to achieve an appropriate balance between detection efficiency and detection results. We have developed an enhanced YOLOv5 algorithm for target detection in high-resolution optical remote sensing images, using multi-layer feature pyramids, multi-detection head strategies and hybrid attention modules to improve the effect of the target detection network in optical remote sensing images. According to the SIMD data set, the mAP of the new algorithm is 2.2% better than YOLOv5 and 8.48% better than YOLOX, achieving a better balance between detection results and speed. 02 Background & Motivation With the rapid development of remote sensing technology, high-resolution optical remote sensing images have been used to describe many objects on the earth’s surface, including aircraft, cars, buildings, etc. Object detection in the interpretation of remote sensing images

VSCode Getting Started Guide: A must-read for beginners to quickly master usage skills! VSCode Getting Started Guide: A must-read for beginners to quickly master usage skills! Mar 26, 2024 am 08:21 AM

VSCode (Visual Studio Code) is an open source code editor developed by Microsoft. It has powerful functions and rich plug-in support, making it one of the preferred tools for developers. This article will provide an introductory guide for beginners to help them quickly master the skills of using VSCode. In this article, we will introduce how to install VSCode, basic editing operations, shortcut keys, plug-in installation, etc., and provide readers with specific code examples. 1. Install VSCode first, we need

C++ program optimization: time complexity reduction techniques C++ program optimization: time complexity reduction techniques Jun 01, 2024 am 11:19 AM

Time complexity measures the execution time of an algorithm relative to the size of the input. Tips for reducing the time complexity of C++ programs include: choosing appropriate containers (such as vector, list) to optimize data storage and management. Utilize efficient algorithms such as quick sort to reduce computation time. Eliminate multiple operations to reduce double counting. Use conditional branches to avoid unnecessary calculations. Optimize linear search by using faster algorithms such as binary search.

Win11 Tricks Revealed: How to Bypass Microsoft Account Login Win11 Tricks Revealed: How to Bypass Microsoft Account Login Mar 27, 2024 pm 07:57 PM

Win11 tricks revealed: How to bypass Microsoft account login Recently, Microsoft launched a new operating system Windows11, which has attracted widespread attention. Compared with previous versions, Windows 11 has made many new adjustments in terms of interface design and functional improvements, but it has also caused some controversy. The most eye-catching point is that it forces users to log in to the system with a Microsoft account. For some users, they may be more accustomed to logging in with a local account and are unwilling to bind their personal information to a Microsoft account.

See all articles