Feedback

  • Contents
 

SQL Server Database Settings

AutoGrowth

Every time a database file or transaction log grows automatically, it takes up a little extra CPU and I/O time. Minimize how often automatic growth occurs by sizing the database and transaction logs as accurately as possible to their final size.

This recommendation is particularly important for transaction logs, because the more often that SQL Server has to increase the size of a transaction log, the more transaction log virtual files that have to be created and maintained by SQL Server. A transaction virtual file is used by SQL Server to internally divide and manage the physical transaction log file.

In SQL Server, database and log files can be set to grow automatically. The default growth amount is 10%. This automatic growth number may or may not be ideal. If the database is growing automatically often (such as daily or several times a week), change the growth percentage to a larger number, such as 20% or 30%. Each time the database has to be increased, SQL Server will suffer a small performance hit. By increasing the amount the database grows each time, the less often it will have to grow.

If your database is very large, 10GB or larger, you may want to use a fixed growth amount instead of a percentage growth amount. This is because a percentage growth amount can be large on a large database. For example, a 10% growth rate on a 10GB database means that when the database grows, it will increase by 1GB. If the percentage growth is too large, change the settings to use a fixed growth size.

Size the database properly, to ensure that the database is not subject to frequent growth. In addition, set the growth increment to a reasonably sufficient value, to prevent the database from growing in numerous, small increments. In this configuration, the Auto grow feature is used as a safeguard only to prevent the database from stopping if it unexpectedly runs out of space. The table below shows typical growth increments for databases of the indicated size.

Database Size

Growth Inc.

Tran Log Size

Growth Inc.

1gb

100 – 200mb

200 – 300mb

50 – 100mb

2gb

200 – 400mb

400 – 600mb

100 – 200mb

3gb

200 – 400mb

600 – 900mb

150 – 250mb

4gb

250 – 400mb

800 – 1000mb

200 – 300mb

5gb

250 – 500mb

1000 – 1500mb

250 – 350mb

6gb

300 – 500mb

1000 – 1700mb

300 – 400mb

7gb

350 – 600mb

1000 – 1850mb

300 – 400mb

8gb

400 – 650mb

1000 – 2000mb

300 – 450mb

9gb

400 – 700mb

1000 – 2400mb

300 – 500mb

10gb

500 – 1000mb

1000 – 2500mb

300 – 500mb

Additionally, the use of a file defragmentation tool is recommended. Be aware that these tools are very resource intensive, so you should only run them when the server is not servicing production requests.

ODBC

Do not use ODBC connection pooling and temporary stored procedures at the same time, or SQL Server will experience a performance hit. When a DSN is used to make a connection from your application to SQL Server, the MDAC driver, by default, converts any dynamic Transact-SQL from the application to temporary stored procedures in SQL Server. The theory behind this is that if the application resends the same Transact-SQL to SQL Server more than once, then it will save the SQL Server overhead of additional parsing and compilation. The recommended configuration consists of turning the convert T-SQL to temporary stored procedure feature off. This feature is configurable from the ODBC Database Wizard when creating or modifying a DSN.

Connection pooling is another option that can be configured using the ODBC Database Wizard when creating or modifying a DSN. It is also on by default, and it pools database connections from the application, which allows connections to be reused, which in turn reduces the overhead of making and breaking database connections. The recommended configuration consists of turning the connection pooling feature on. Note that pooling improves performance more than temporary stored procedures.

The problem is that if both of these options are on, which is often the case in DSNs, SQL Server can take a performance hit. Here's what can happen: When dynamic Transact-SQL is converted into a temporary stored procedure by the MDAC driver, the temporary stored procedure is stored in the tempdb database. When connection pooling is not enabled, and the connection between the client application and SQL Server is ended, any temporary stored procedures created during the connection are deleted. But, when connection pooling is enabled, things work differently. When a database connection is ended by the client application, it is not ended at SQL Server. SQL Server still thinks the connection is still open, even though the client application does not. This means the temporary stored procedures created during the connection are not deleted. With a busy client application that often starts and stops database connections, the tempdb database can fill up with temporary stored procedures, putting unnecessary overhead on SQL Server.