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:
$settings = [
    "Databases.QueryTimeoutInSec" => "350",
    "Indexing.Static.DeploymentMode" => "Rolling"
];

// Define the put database settings operation,
// specify the database name & pass the settings dictionary
$putDatabaseSettingsOp = new PutDatabaseSettingsOperation($documentStore->getDatabase(), $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
$disableDatabaseOp = new ToggleDatabasesStateOperation($documentStore->getDatabase(), true);
$documentStore->maintenance()->server()->send($disableDatabaseOp);

// Enable database
$enableDatabaseOp = new ToggleDatabasesStateOperation($documentStore->getDatabase(), false);
$documentStore->maintenance()->server()->send($enableDatabaseOp);

Syntax:

PutDatabaseSettingsOperation(?string $databaseName, StringMap|array|null $configurationSettings)
Parameter Type Description
$databaseName ?string Name of the database to change the settings for.
$configurationSettings StringMap
array
null
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
$getDatabaseSettingsOp = new GetDatabaseSettingsOperation($documentStore->getDatabase());

// Execute the operation by passing it to Maintenance.Send
/** @var DatabaseSettings $customizedSettings */
$customizedSettings = $documentStore->maintenance()->send($getDatabaseSettingsOp);

// Get the customized value
$customizedValue = $customizedSettings->getSettings()["Databases.QueryTimeoutInSec"];

Syntax:

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

// Executing the operation returns the following object:
class DatabaseSettings
{
// Configuration settings that have been customized
    private ?StringMap $settings = null;
    // ...getter and setter
}