SQL Server server optimization skills

Source: Internet
Author: User

1. Data and log files are stored separately on different disks.

Operations on data files and log files generate a large amount of I/O. If possible, log files should be stored on a hard disk different from the data files where the data and indexes are located to distribute I/O, and facilitate database disaster recovery.

2. The tempdb database is stored separately on different disks.

The tempdb database is a temporary database that all other databases may use. When select into is used and orderby is executed on columns without an index, a temporary table is generated in the tempdb database to store intermediate data. Creating and filling temporary tables will seriously reduce system performance, so you should create an index for the columns to be sorted as much as possible. At the same time, the tempdb database is for all users and applications.ProgramShare, so if a user occupies all the space of the tempdb database, other databases will no longer be available. If possible, the tempdb database should be placed separately on a faster hard disk or raid array. Separates I/O operations on the tempdb database to accelerate performance. The tempdb database should have appropriate capacity to meet user needs. The automatic increase in the space of the tempdb database should be allowed. If it is set to not allow automatic growth, when the query operation creates a temporary table that exceeds the tempdb database capacity, the operation cannot be completed.

Appropriately set the growth margin of the tempdb database. A small growth margin will generate more external fragments and occupy more resources.

3. Avoid hotspot data

Before sqlserver7.0, for tables without clustered indexes (heap tables), newly inserted data rows are always placed at the physical end of the table on the disk. If a large number of concurrent users insert or update data to the table at the same time, this may lead to data hotspots at the end of a very busy table. Concurrent I/O operations are performed on a few pages in a centralized manner, which will lead to a decline in database performance.

In sqlserver, the physical storage space of new data rows is allocated through the PFS page. PFS Page ManagementAlgorithmDistribute the insert operations to avoid data hotspots.

When designing application systems and databases, avoid creating primary keys on columns with natural growth, which may lead to hotspot data.

4. Fewer Data Types

Use as few data types as possible when designing tables. Such a data page can save the most information. There are fewer data pages and fewer I/O operations on the retrieved data pages, which results in high efficiency.

5. Monitor and organize space fragments

The automatic increase of file space increases the automatic management, but may lead to space fragmentation. The logical space of physical space and data is no longer consecutive. Regular monitoring and space fragmentation helps improve I/O performance.

6. Use primary and secondary data files

One primary data file of each database belongs to the primary file group. For a database of about 1 GB, a data file is enough. If there are secondary data files, the primary data file contains pointers for managing secondary data files.

When multiple data files are used, the primary data files are used to store system objects and tables, and secondary data files are used to store user data and indexes. If possible, the primary and secondary data files can be separately stored on different disks to distribute I/O.

If multiple data files are used, it is recommended that the primary data file store system data and secondary data files store user data and indexes, which will help improve I/O performance.

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.