How to optimize SQL Server server

In China, the use SQLServer database of users and business is the largest, how to design and optimize server SQLSerer it, DBA should follow those guidelines and methods for it, the following will share my experience with you, we want to help.

AD:

 

1. The data and log files are kept separately on different disks

Manipulate data files and log files will produce large amounts of I / O. Where possible conditions, the log files should be stored on a different data file and index data resides hard to spread I / O, while fostering the database disaster recovery.

2.tempdb database separately stored in different disk

tempdb database is a temporary database to all other databases are likely to be used. When select into, the temporary table is generated in the tempdb database when executed on a Orderby not indexed columns to store intermediate data. Since the establishment and filling temporary table will seriously reduce system performance, so it should be indexed to sort columns whenever possible. Meanwhile, tempdb database is shared for all users and applications, so if a user occupies all the space tempdb database, other databases will no longer be used. In the possible, tempdb database should be placed separately on a hard drive or faster RAID array. Isolated tempdb database I / O operations to speed up performance. tempdb database should have the appropriate capacity to meet the needs of users. Tempdb database should be allowed room to grow automatically. If set to allow automatic growth, when the query operations over the establishment of a temporary table tempdb database capacity, the operation will not be completed.

Properly set tempdb database growth, the growth rate is too small will produce more external fragmentation takes up more resources.

3. avoid the occurrence of hot data

Before SQLServer7.0, no clustered index for a table (table heap), the newly inserted data line is always placed at the physical end of the disk table. If the number of concurrent users, while performing the operation of inserting or update the data table, which will make the end of the table is heavy data hot spots may occur. Concurrent I / O operations focus on a few pages, could result in decreased performance of the database.

In SQLServer, the physical storage space allocated to the new line of data is performed by the PFS page. PFS page management algorithm will be dispersed to insert data generation avoid hot spots.

When designing applications and databases, to avoid the establishment of a primary key column on natural growth, which may lead to the occurrence of hot data.

4. The type of data to less

In the design table, as little as possible with the data type. This can save a maximum amount of information on the data page. Less data page, retrieve the data page I / O operation is small, so the efficiency will be high.

5. Monitor and sort of space debris

Automatic growth of file space to improve the automated management, but may result in space debris. Logical space and a physical space is no longer continuous data. Regular monitoring and space defragmentation will help improve I / O performance.

6. Use main data file and the secondary data files

A master data file for each part of the main database file group. For approximately the size of 1GB database, a data file is enough, if there is secondary data files, master data file has a pointer for managing the secondary data file.

When using a plurality of data files, the primary data storage system for file objects and tables, secondary data files for storing user data and indexes. Where possible, the main data file and the secondary data files can be stored separately on different disks to disperse the I / O.

If a plurality of data files, the data file storage system recommended primary data, secondary data files stored user data and index, this will help to improve I / O performance.

7. Use file groups to improve performance

In large database systems, you can consider the establishment of file groups to manage data files. The tables and indexes to compare performance monitoring through stored in different physical disks, the conclusion that optimal storage solutions.

8. attention to performance problems automatically grow and shrink automatically may result

Automatic growth of the database files and automatically systolic function is useful for managing small databases. But it can cause performance problems of large databases. Because the natural growth of the file will also lead to memory fragmentation. When the file space becomes larger, the new allocation of space and the original space is not necessarily continuous. When the file space contraction, release some space. However, when the document also need to increase storage space but can not use the original release, it will lead to fragmentation.

9. The isolated system data and user data

The system and user databases separately stored in different physical disks help to improve I / O performance, help database backup and recovery.

10. Optimization of the index design

Index design is very important to the performance of the database. Which will not be explained, can be found in the Bo articles.

11. regularly updated statistics

SQLServer default cost-based optimization, so to update the statistical information is important for query optimization.

12. Periodic consistency checks

Database consistency check on a regular basis to ensure the integrity of the database.

Reproduced in: https: //www.cnblogs.com/flysun0311/archive/2012/03/07/2383338.html

Guess you like

Origin blog.csdn.net/weixin_33912453/article/details/93444294