Skip to main content
ALTER SYSTEM is an advanced system performance tuning feature for configuring and retrieving system settings for your peer-to-peer mesh network.
For information on specific configs supported via ALTER SYSTEM reach out to the Ditto team member.
System settings consist of values the Ditto library uses to configure specific behaviors, such as timeouts, resource limits, and so on. This article provides a high-level overview of the ALTER SYSTEM Ditto Query Language (DQL) statement, as well as instructions on how to use it, once offered, to set, reset, and query peer-to-peer system settings.

Tasks Overview

The following table provides an overview of the various tasks you can perform with the ALTER SYSTEM statement:

Retrieving Values

Fetch current setting values for either the entire mesh network or a specific setting:
  • To return system-wide configurations, use a SHOW ALL statement:
  • To return only the value for a specific setting, pass the setting you want to retrieve a value for in a SHOW statement. For example:

Executing SHOW and SHOW ALL

To invoke your statement, call the Execute API method on the ditto.store namespace:

Modifying Values

To modify a system setting, use ALTER SYSTEM SET:
Similar to PostgresSQL, DQL supports both the = and TO syntax for setting system configurations.Regardless of the syntax you use in your ALTER SYSTEM SET query, the documents Ditto returns contain the current value of the setting, identified by the setting name.
For example:

Executing SET

Similar to the execution pattern recommended when configuring transports in your app, invoke your statement modifying system configurations immediately after initializing the ditto object. (See Customizing Transports Configurations)
When you execute ALTER SYSTEM through the SDK API, Ditto stores the changed settings in memory rather than persisting them to disk.As of SDK 5.1, ALTER SYSTEM statements sent through Remote Query persist their overrides across restarts on native peers with persistent storage. These overrides take precedence over Ditto instance configuration and environment variables. A later ALTER SYSTEM call through the SDK API takes precedence for the current instance.Some settings take effect only during initialization, before the Ditto instance is available to your app. Although you can execute ALTER SYSTEM at any point in your app’s lifecycle, changes to these settings do not take effect immediately.
To invoke the SET statement, add a call to the Execute API method on the ditto.store namespace.

Resetting Values to Default

To return peer-to-peer system configuration settings to default values, do either of the following:
  • To reset all configuration settings: For example:
  • To reset a specific configuration setting:
Once executed, Ditto returns a document containing current values, identified by their setting name.

Troubleshooting

Ditto throws an error when an ALTER SYSTEM query operation fails to execute due to various issues, including:
  • Syntax mistakes, such as a typo, causing parsing of the DQL statement to fail.
  • Using an unrecognized setting name in the query (often due to a typo).
  • Attempting to set a value outside the acceptable bounds for a setting in an ALTER SYSTEM SET query.
  • An internal error occurred while processing the query.