# Database settings

The server exposes effective database settings in system.settings. `SET` persists log_queries, log_queries_min_query_duration_ms, max_execution_time, max_memory_usage, max_result_rows, max_response_bytes and max_threads for the selected database. Other connected clients observe committed values before later requests.

Changes require a selected database, autocommit and no active transactions in that database. Resource values are sampled once per request; a SET in a multi-statement request changes defaults for later requests.

The foreign_keys, recursive_triggers, user_version and application_id rows use [PRAGMA or catalog writes](https://coordinatordb.com/docs/reference/settings/session-settings/other); SET does not accept these four names. A nonzero server XML request ceiling can only be tightened by database settings; 0 means no additional limit at that level.

## Defaults

| Setting                             | Type      | Default | Meaning                                                                                               |
| ----------------------------------- | --------- | ------- | ----------------------------------------------------------------------------------------------------- |
| `application_id`                    | `Int32`   | `0`     | Application-managed database file identifier.                                                         |
| `foreign_keys`                      | `Bool`    | `0`     | Enforce foreign-key constraints in database sessions.                                                 |
| `log_queries`                       | `Bool`    | `1`     | Record TCP and HTTP requests in the structured query journal.                                         |
| `log_queries_min_query_duration_ms` | `UInt64`  | `0`     | Minimum logged request duration in milliseconds.                                                      |
| `max_execution_time`                | `Float64` | `0`     | Maximum SQL processing time in seconds; zero disables the limit.                                      |
| `max_memory_usage`                  | `UInt64`  | `0`     | Maximum live SQL heap bytes; zero disables the limit.                                                 |
| `max_response_bytes`                | `UInt64`  | `0`     | Maximum formatted native response bytes; zero disables this setting.                                  |
| `max_result_rows`                   | `UInt64`  | `0`     | Maximum cumulative returned rows per request; zero disables the limit.                                |
| `max_threads`                       | `UInt64`  | `0`     | Maximum threads per query, from 0 through 64. Zero selects automatically; one keeps execution serial. |
| `recursive_triggers`                | `Bool`    | `0`     | Allow triggers to invoke themselves recursively.                                                      |
| `user_version`                      | `Int32`   | `0`     | Application-managed database schema version.                                                          |

## Inspect effective values

```sql
SELECT name,value,type,"default" FROM system.settings WHERE readonly=0 ORDER BY name FORMAT csv;
```

```text
"application_id","0","Int32","0"
"foreign_keys","0","Bool","0"
"log_queries","1","Bool","1"
"log_queries_min_query_duration_ms","0","UInt64","0"
"max_execution_time","0","Float64","0"
"max_memory_usage","0","UInt64","0"
"max_response_bytes","0","UInt64","0"
"max_result_rows","0","UInt64","0"
"max_threads","0","UInt64","0"
"recursive_triggers","0","Bool","0"
"user_version","0","Int32","0"
```

The changed column compares an effective value with its built-in default. Server ceilings can make the effective value differ from the saved value in main.settings. Format options appear separately as read-only defaults; server-only XML options are not listed.
