Database Settings Operations


Do not modify the database settings unless you are an expert and know what you're doing.

Put database settings operation

  • Use PutDatabaseSettingsOperation to modify the default database configuration.

  • Only database-level settings can be customized using this operation.
    See the Configuration overview article to learn how to customize the server-level settings.

  • Note: for the changes to take effect, the database must be reloaded.
    Reloading is accomplished by disabling and enabling the database using ToggleDatabasesStateOperation.
    See the following example:

// 1. Modify the database settings:
// ================================

// Define the settings dictionary with the key-value pairs to set, for example:
var settings = new Dictionary<string, string>
{
    ["Databases.QueryTimeoutInSec"] = "350", 
    ["Indexing.Static.DeploymentMode"] = "Rolling"
};

// Define the put database settings operation,
// specify the database name & pass the settings dictionary
var putDatabaseSettingsOp = new PutDatabaseSettingsOperation(documentStore.Database, settings);
    
// Execute the operation by passing it to Maintenance.Send
documentStore.Maintenance.Send(putDatabaseSettingsOp);
    
// 2. RELOAD the database for the change to take effect:
// =====================================================

// Disable database
var disableDatabaseOp = new ToggleDatabasesStateOperation(documentStore.Database, true);
documentStore.Maintenance.Server.Send(disableDatabaseOp);

// Enable database
var enableDatabaseOp = new ToggleDatabasesStateOperation(documentStore.Database, false);
documentStore.Maintenance.Server.Send(enableDatabaseOp); 
// 1. Modify the database settings:
// ================================

// Define the settings dictionary with the key-value pairs to set, for example:
var settings = new Dictionary<string, string>
{
    ["Databases.QueryTimeoutInSec"] = "350", 
    ["Indexing.Static.DeploymentMode"] = "Rolling"
};

// Define the put database settings operation,
// specify the database name & pass the settings dictionary
var putDatabaseSettingsOp = new PutDatabaseSettingsOperation(documentStore.Database, settings);
    
// Execute the operation by passing it to Maintenance.SendAsync
await documentStore.Maintenance.SendAsync(putDatabaseSettingsOp);
    
// 2. RELOAD the database for the change to take effect:
// =====================================================

// Disable database
var disableDatabaseOp = new ToggleDatabasesStateOperation(documentStore.Database, true);
await documentStore.Maintenance.Server.SendAsync(disableDatabaseOp);

// Enable database
var enableDatabaseOp = new ToggleDatabasesStateOperation(documentStore.Database, false);
await documentStore.Maintenance.Server.SendAsync(enableDatabaseOp); 

Syntax:

PutDatabaseSettingsOperation(string databaseName, Dictionary<string, string> configurationSettings)
Parameter Type Description
databaseName string Name of database for which to change the settings.
configurationSettings Dictionary<string, string> The configuration settings to set.

Get database settings operation

  • Use GetDatabaseSettingsOperation to get the configuration settings that were customized for the database.

  • Only settings that have been changed will be retrieved.

// Define the get database settings operation, specify the database name
var getDatabaseSettingsOp = new GetDatabaseSettingsOperation(documentStore.Database);
    
// Execute the operation by passing it to Maintenance.Send
var customizedSettings = documentStore.Maintenance.Send(getDatabaseSettingsOp);

// Get the customized value
var customizedValue = customizedSettings.Settings["Databases.QueryTimeoutInSec"];
// Define the get database settings operation, specify the database name
var getDatabaseSettingsOp = new GetDatabaseSettingsOperation(documentStore.Database);
    
// Execute the operation by passing it to Maintenance.SendAsync
var customizedSettings = await documentStore.Maintenance.SendAsync(getDatabaseSettingsOp);

// Get the customized value
var customizedValue = customizedSettings.Settings["Databases.QueryTimeoutInSec"];

Syntax:

GetDatabaseSettingsOperation(string databaseName)
Parameter Type Description
databaseName string The database name for which to get the customized settings.

// Executing the operation returns the following object:
public class DatabaseSettings
{
    // Configuration settings that have been customized
    public Dictionary<string, string> Settings { get; set; }
}