> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ditto.live/llms.txt
> Use this file to discover all available pages before exploring further.

# ALTER SYSTEM

> The ALTER SYSTEM statement allows you to modify configuration parameters at runtime without restarting your Ditto instance.

> [!NOTE]
>
> `ALTER SYSTEM` is available in SDK v5+.

The `ALTER SYSTEM` statement provides runtime configuration management, allowing you to change system parameters dynamically.

## Syntax

```sql DQL theme={null}
ALTER SYSTEM SET parameter_name TO value
ALTER SYSTEM SET parameter_name = value
ALTER SYSTEM RESET parameter_name
ALTER SYSTEM RESET ALL
```

![ALTER SYSTEM Syntax Diagram](https://mintcdn.com/ditto-248bc0d1/pf3IlRElveI85RoM/images/dql/AlterSystem.svg?fit=max\&auto=format\&n=pf3IlRElveI85RoM\&q=85\&s=f6246e953fad3c259d9c7afd0e32ad22)

## SET Parameter

Change a configuration parameter to a specific value:

```sql DQL theme={null}
-- Using TO syntax
ALTER SYSTEM SET DQL_STRICT_MODE TO false

-- Using = syntax (equivalent)
ALTER SYSTEM SET DQL_STRICT_MODE = false
```

### Set to DEFAULT

Reset a parameter to its default value using the `DEFAULT` keyword:

```sql DQL theme={null}
ALTER SYSTEM SET parameter_name TO DEFAULT
```

## RESET Parameter

Reset a configuration parameter to its default value:

```sql DQL theme={null}
-- Reset single parameter
ALTER SYSTEM RESET DQL_STRICT_MODE

-- Reset all parameters to defaults
ALTER SYSTEM RESET ALL
```

## Parameter Values

Parameter values can be:

* **Literals**: Numbers, strings, booleans
  * Boolean: `true`, `false`
  * Integer: `100`, `5000`
  * String: `'value'` or `"value"`
* **DEFAULT keyword**: Resets to the default value

## Available DQL Configuration Parameters

### DQL\_STRICT\_MODE

**Type**: Boolean
**Default**: `true` in SDK 4.x, `false` in SDK 5.0 and later

Controls whether strict mode is enabled for collection type definitions. In SDK 5.2 and later, set `DQL_STRICT_MODE` in the system parameters of `DittoConfig` instead of with `ALTER SYSTEM`. See [Strict Mode](https://docs.ditto.live/dql/strict-mode.md) for details and examples.

### DQL\_DEFAULT\_DIRECTIVES

**Type**: Object (JSON)
**Default**: `{}`

Sets default query directives that apply to all queries. Individual query directives can override these defaults.

```sql DQL theme={null}
-- Set default directives for development
ALTER SYSTEM SET DQL_DEFAULT_DIRECTIVES = {"#reprepare": true, "#max_serial_ranges": 2}

-- Reset to no default directives
ALTER SYSTEM SET DQL_DEFAULT_DIRECTIVES = {}
```

See [Directives](https://docs.ditto.live/dql/directives.md#default-directives) for more information.

### DQL\_CONCURRENT\_REQUEST\_LIMIT

**Type**: Integer
**Default**: System-dependent

Limits the number of concurrent DQL requests that can execute simultaneously. When the limit is reached, additional requests are queued until capacity becomes available.

```sql DQL theme={null}
-- Limit to 10 concurrent requests
ALTER SYSTEM SET DQL_CONCURRENT_REQUEST_LIMIT TO 10

-- Reset to default (no limit)
ALTER SYSTEM RESET DQL_CONCURRENT_REQUEST_LIMIT
```

> [!NOTE]
>
> This parameter helps prevent resource exhaustion under heavy query load by controlling the maximum number of queries running at once.

### DQL\_SLOW\_REQUEST\_WARN\_SECONDS

**Type**: Integer (seconds)
**Default**: `60`

Sets the threshold, in seconds, after which a still-running DQL request is considered slow. Once a request has been executing for this long, Ditto writes a warning log entry containing the request's details — the same information reported by [system:active\_requests](https://docs.ditto.live/dql/virtual-collections.md#systemactive_requests) — and repeats the warning every `DQL_SLOW_REQUEST_WARN_SECONDS` seconds for as long as the request keeps running.

```sql DQL theme={null}
-- Warn about requests still running after 30 seconds
ALTER SYSTEM SET DQL_SLOW_REQUEST_WARN_SECONDS TO 30
```

> [!NOTE]
>
> Set to `0` to disable slow-request warnings entirely.

### DQL\_REQUEST\_TIMEOUT\_SECONDS

**Type**: Integer (seconds)
**Default**: `0` (disabled)

Limits how long, in seconds, a DQL request is permitted to run before it is cancelled. When a request exceeds this limit, its execution pipeline is signalled to stop and the request fails with a timeout error; a warning log entry containing the request's details is also written.

```sql DQL theme={null}
-- Cancel requests that run longer than 45 seconds
ALTER SYSTEM SET DQL_REQUEST_TIMEOUT_SECONDS TO 45
```

> [!NOTE]
>
> Set to `0` (the default) to disable the timeout, allowing requests to run for as long as they need.

> [!WARNING]
>
> Cancellation is cooperative rather than immediate: the currently executing operator is not interrupted mid-step, so execution may continue briefly past the configured limit before it actually stops.

## Available Transport Configuration Parameters

### tcp\_server\_bind\_mdns\_server\_port

**Type**: Integer
**Default**: Random port

Specifies the port that a Small Peer SDK instance uses for mDNS announcements and incoming LAN (TCP) connections on the local device. Setting an explicit port is useful when you need to traverse a VLAN or firewall by scanning for open ports, or when you need a deterministic port for network policy.

Leaving the parameter unset preserves the default behavior of binding to a random port.

```sql DQL theme={null}
ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234
```

> [!WARNING]
>
> If you run multiple Ditto applications on the same device — for example a debug or TestFlight build alongside a production build — each application must use a unique port. Otherwise only one application will be able to establish LAN connections at a time.

> [!WARNING]
>
> `tcp_server_bind_mdns_server_port` must be set **before** sync is started for the value to take effect.

```swift Swift theme={null}
let result = try await ditto.store.execute(
  query: "ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234"
)
```

```kotlin Kotlin theme={null}
val result = ditto.store.execute("ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234")
```

```javascript JS theme={null}
const result = await ditto.store.execute("ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234");
```

```java Java theme={null}
DittoQueryResult result = ditto.store.execute("ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234");
```

```csharp C# theme={null}
var result = await ditto.Store.ExecuteAsync("ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234");
```

```cpp C++ theme={null}
auto result = ditto.get_store().execute("ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234").get();
```

```rust Rust theme={null}
let result = ditto.store()
    .execute_v2((
        "ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234",
        serde_json::json!({})
    ))
    .await?;
```

```dart Dart theme={null}
final result = await ditto.store.execute("ALTER SYSTEM SET tcp_server_bind_mdns_server_port TO 1234");
```

See [Local Area Network](https://docs.ditto.live/sdk/latest/deployment/network-deployment.md) for the underlying mDNS, TCP, and firewall behavior this parameter affects.

## Common Use Cases

### Configure Default Query Directives

```sql DQL theme={null}
-- Set default directives during development
ALTER SYSTEM SET DQL_DEFAULT_DIRECTIVES = {"#reprepare": true}

-- Clear default directives for production
ALTER SYSTEM SET DQL_DEFAULT_DIRECTIVES = {}
```

### Control Concurrent Query Execution

```sql DQL theme={null}
-- Limit concurrent queries to prevent overload
ALTER SYSTEM SET DQL_CONCURRENT_REQUEST_LIMIT TO 20

-- Remove limit
ALTER SYSTEM RESET DQL_CONCURRENT_REQUEST_LIMIT
```

### Reset All Configuration

```sql DQL theme={null}
-- Reset all parameters to their default values
ALTER SYSTEM RESET ALL
```

## Examples

```swift Swift theme={null}
// Set strict mode
await ditto.store.execute(
  query: "ALTER SYSTEM SET DQL_STRICT_MODE TO false"
)

// Reset parameter
await ditto.store.execute(
  query: "ALTER SYSTEM RESET DQL_STRICT_MODE"
)

// Reset all parameters
await ditto.store.execute(
  query: "ALTER SYSTEM RESET ALL"
)
```

```kotlin Kotlin theme={null}
// Set strict mode
ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE TO false")

// Reset parameter
ditto.store.execute("ALTER SYSTEM RESET DQL_STRICT_MODE")

// Reset all parameters
ditto.store.execute("ALTER SYSTEM RESET ALL")
```

```javascript JS theme={null}
// Set strict mode
await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE TO false");

// Reset parameter
await ditto.store.execute("ALTER SYSTEM RESET DQL_STRICT_MODE");

// Reset all parameters
await ditto.store.execute("ALTER SYSTEM RESET ALL");
```

```java Java theme={null}
// Set strict mode
ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE TO false");

// Reset parameter
ditto.store.execute("ALTER SYSTEM RESET DQL_STRICT_MODE");

// Reset all parameters
ditto.store.execute("ALTER SYSTEM RESET ALL");
```

```csharp C# theme={null}
// Set strict mode
await ditto.Store.ExecuteAsync("ALTER SYSTEM SET DQL_STRICT_MODE TO false");

// Reset parameter
await ditto.Store.ExecuteAsync("ALTER SYSTEM RESET DQL_STRICT_MODE");

// Reset all parameters
await ditto.Store.ExecuteAsync("ALTER SYSTEM RESET ALL");
```

```cpp C++ theme={null}
// Set strict mode
ditto.get_store().execute("ALTER SYSTEM SET DQL_STRICT_MODE TO false").get();

// Reset parameter
ditto.get_store().execute("ALTER SYSTEM RESET DQL_STRICT_MODE").get();

// Reset all parameters
ditto.get_store().execute("ALTER SYSTEM RESET ALL").get();
```

```rust Rust theme={null}
// Set strict mode
ditto.store()
    .execute_v2((
        "ALTER SYSTEM SET DQL_STRICT_MODE TO false",
        serde_json::json!({})
    ))
    .await?;

// Reset parameter
ditto.store()
    .execute_v2((
        "ALTER SYSTEM RESET DQL_STRICT_MODE",
        serde_json::json!({})
    ))
    .await?;

// Reset all parameters
ditto.store()
    .execute_v2((
        "ALTER SYSTEM RESET ALL",
        serde_json::json!({})
    ))
    .await?;
```

```dart Dart theme={null}
// Set strict mode
await ditto.store.execute("ALTER SYSTEM SET DQL_STRICT_MODE TO false");

// Reset parameter
await ditto.store.execute("ALTER SYSTEM RESET DQL_STRICT_MODE");

// Reset all parameters
await ditto.store.execute("ALTER SYSTEM RESET ALL");
```

## Checking Current Values

To verify the current value of a parameter after changing it, use the [SHOW](https://docs.ditto.live/dql/show.md) statement:

```sql DQL theme={null}
-- Set parameter
ALTER SYSTEM SET DQL_STRICT_MODE TO false

-- Verify the change
SHOW DQL_STRICT_MODE
```

> [!NOTE]
>
> Configuration changes made with `ALTER SYSTEM` are **runtime only** and do not persist across restarts. To apply settings on every startup, set the parameters in your Ditto instance configuration before starting.

## See Also

* [SHOW](https://docs.ditto.live/dql/show.md) - Display configuration parameter values
* [Strict Mode](https://docs.ditto.live/dql/strict-mode.md) - Understanding DQL\_STRICT\_MODE parameter
* [Virtual Collections](https://docs.ditto.live/dql/virtual-collections.md#systemactive_requests) - Inspect currently executing and completed requests


## Related topics

- [Customizing System Settings](https://docs.ditto.live/sdk/latest/sync/using-alter-system.md)
- [C++ Release Notes](https://docs.ditto.live/sdk/v4/release-notes/cpp.md)
- [C# Release Notes](https://docs.ditto.live/sdk/v4/release-notes/c-sharp.md)
