Database attribute management

更新时间:
复制 MD 格式

View or modify ApsaraDB RDS for SQL Server database attributes in the console. You can also shrink the database transaction log and update database statistics to optimize performance and query efficiency.

Prerequisites

A database is created.

View or modify database attributes

Precautions

Modifying certain database attributes causes the database to temporarily enter exclusive mode. This disconnects all current connections and rolls back existing transactions. If the database is under a high load, the modification may fail. We recommend that you perform this operation during off-peak hours.

Note

Exclusive mode allows only one user or process to operate on the database at a time.

Procedure

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the left-side navigation pane, click Databases.

  3. Find the target database. In the Actions column, click View Details to view its attribute values.

    Note

    For a detailed description of each attribute, see Appendix: Database attributes or the official Microsoft documentation.

  4. In the Allowed Values column, modify an attribute's value and click Submit.

    For example, for the parameterization attribute, select SIMPLE or FORCED from the drop-down list, and then click Submit at the right of the corresponding row.

Shrink the database transaction log

Scenarios

If the used space of the transaction log file (LogUsedSizeInMB) is small relative to its total size (TotalLogSizeInMB) and the log_reuse_wait_desc attribute is Nothing, you can shrink the transaction log to reduce disk space usage.

Procedure

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the left-side navigation pane, click Databases.

  3. In the Actions column, choose More > Shrink Database Transaction Logs.

  4. Click OK.

Update database statistics

As the volume and distribution of data in a database change over time, periodically updating statistics helps maintain accurate and efficient query optimization.

Scenarios

  • During a major version upgrade, the new version may introduce new data types, storage engines, or query optimizers, which can render old statistics inaccurate. Update statistics to adapt to the new engine.

  • When you migrate a database from an on-premises deployment to the cloud, the change in environment may require re-optimized performance. Update statistics to improve query performance and optimize query plans.

  • If your business data is unevenly distributed, if you perform a large number of delete or update operations but the updated volume is less than 20%, or in other scenarios not covered by the built-in automatic statistics updates of SQL Server, update statistics to improve query performance.

    Note

    By default, SQL Server automatically updates statistics. However, the frequency of automatic updates may lag behind actual data changes, which can degrade query performance. For more information about the automatic statistics update mechanism of SQL Server, see the official Microsoft documentation.

Precautions

Updating statistics can cause high I/O usage. We recommend that you perform this operation during off-peak hours.

Procedure

  1. Go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the ID of the instance.

  2. In the left-side navigation pane, click Databases.

  3. In the Actions column, choose More > Update Database Statistics.

  4. Click OK.

Appendix: Database attributes

Basic information

Parameter

Description

page_verify

The verification level of database pages. The default value is CHECKSUM, which verifies each data page by its checksum.

target_recovery_time_in_seconds

The target recovery time, in seconds, for the database in the event of a failure. The default value is 60.

compatibility_level

The database compatibility level for a specific SQL Server version. Valid values:

  • 100: SQL Server 2008 and later.

  • 110: SQL Server 2012 and later.

  • 120: SQL Server 2014 and later.

  • 130: SQL Server 2016 and later.

  • 140: SQL Server 2017 and later.

  • 150: SQL Server 2019 and later.

  • 160: SQL Server 2022 and later.

parameterization

How SQL Server handles parameterization. Valid values:

  • SIMPLE: Parameterizes only queries with simple constant parameters. (Default)

  • FORCED: Forces parameterization for all queries.

read_committed_snapshot

Whether to use snapshot isolation when data is read. Valid values:

  • OFF: Disables READ COMMITTED SNAPSHOT and uses traditional read locking. (Default)

  • ON: Enables READ COMMITTED SNAPSHOT and allows concurrent read operations that are not blocked by write operations.

collation_name

The collation and character encoding of the database. For more information, see Change the character set collation and time zone.

auto_close

Whether to automatically close the database connection. The default value is OFF (disabled).

recovery_model_desc

The recovery model of the database. The default value is FULL, which indicates the full recovery model.

auto_update_statistics

Whether to enable automatic statistics updates. Valid values:

  • ON: Enabled (Default)

  • OFF: Disabled

auto_update_statistics_async

Whether to update statistics asynchronously. Valid values:

  • OFF: Statistics are updated synchronously. (Default)

  • ON: Statistics are updated asynchronously.

allow_snapshot_isolation

Whether to enable the snapshot isolation level. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

state_desc

The status of the database. ONLINE indicates that the database is online.

create_date

The time when the database was created.

log_reuse_wait_desc

The reason the current transaction log cannot be reused. NOTHING indicates that no conditions are preventing log reuse.

Runtime information

Parameter

Description

TotalDataSizeInMB

The total size of the database data files, in MB.

DataUsedSizeInMB

The space used by the database data files, in MB.

TotalLogSizeInMB

The total size of the database log files, in MB.

LogUsedSizeInMB

The space used by the database log files, in MB.

VLFCount

The number of virtual log files (VLFs) in the database.

LastestBackupTime

The time of the last database backup.

LastestBackupType

The type of the last database backup. Valid values:

  • D: Database, full backup.

  • I: Differential, differential backup.

  • L: Log, log backup.

Advanced information

Parameter

Description

accelerated_database_recovery

Whether to enable Accelerated Database Recovery (ADR). ADR provides fast database recovery by using versioned storage and logical rollback, significantly reducing downtime caused by restarts or failures. This feature is suitable for OLTP systems with frequent long-running transactions that require high availability. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

Note
  • Supported only on Standard Edition and Enterprise Edition instances that run SQL Server 2019 or later.

  • Enabling ADR can significantly reduce recovery time for long-running transactions and improve system availability, but it increases storage consumption and introduces a minor performance overhead.

ansi_nulls

Whether to enable ANSI NULL behavior. When enabled, comparisons with NULL always return UNKNOWN instead of TRUE or FALSE. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

recursive_triggers

Whether to allow triggers to fire recursively. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

delayed_durability

Whether to enable delayed durability. Delayed durability allows transactions to write data to disk asynchronously after a commit, improving transaction throughput. Valid values:

  • DISABLED: Disables delayed durability. Transactions are written to disk synchronously after a commit. (Default)

  • ALLOWED: Enables delayed durability, but does not require all transactions to use it.

  • FORCED: Forces delayed durability. All transactions must use delayed durability.

ansi_warnings

Whether to enable ANSI warnings. When enabled, warnings are returned for operations that cause warning conditions. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

ansi_null_default

Whether a column accepts NULL values when you insert data and the specified value is NULL. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

ansi_padding

Whether to enable ANSI padding. When enabled, if the inserted data is shorter than the defined column length, padding characters are added. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

db_owner

The owner of the database. The database owner has the highest level of permissions, including deleting the database, modifying all objects, and managing user permissions. The default value is typically the account that created the database. The owner must be a valid user account in the current instance.

Note

Modifying the db_owner attribute directly changes the database's owner, affecting the database's security principal. In contrast, setting an account's permission for the database to "Owner" on the account management page assigns the db_owner role to the account. This is a permission assignment and does not change the database's ownership principal.

concat_null_yields_null

Whether concatenating a value with NULL returns NULL. When enabled, any string concatenation involving NULL produces a NULL result. Valid values:

  • OFF: Disabled (Default)

  • ON: Enabled

Related API

You can modify the attributes of an ApsaraDB RDS for SQL Server database by calling the ModifyDatabaseConfig API.