Skip to content
© 2026 The ThingsBoard Authors
Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

Database Configuration

All parameters listed here correspond to settings in tb-edge.yml (or tb-edge.conf on Linux). Set them as environment variables in /etc/tb-edge/conf/tb-edge.conf (Linux) or as container environment variables (Docker / Kubernetes). For instructions on applying changes, see How to change configuration.

Parameter Env variable Default Description
database.ts_max_intervals DATABASE_TS_MAX_INTERVALS 700 Max number of DB queries generated by a single API call to fetch telemetry records
database.ts.type DATABASE_TS_TYPE sql sql or timescale (for hybrid mode, DATABASE_TS_TYPE value should be timescale)
database.ts_latest.type DATABASE_TS_LATEST_TYPE sql sql or timescale (for hybrid mode, DATABASE_TS_TYPE value should be timescale)
Parameter Env variable Default Description
sql.attributes.batch_size SQL_ATTRIBUTES_BATCH_SIZE 1000 Batch size for persisting attribute updates
sql.attributes.batch_max_delay SQL_ATTRIBUTES_BATCH_MAX_DELAY_MS 50 Max timeout for attributes entries queue polling. The value is set in milliseconds
sql.attributes.stats_print_interval_ms SQL_ATTRIBUTES_BATCH_STATS_PRINT_MS 10000 Interval in milliseconds for printing attributes updates statistic
sql.attributes.batch_threads SQL_ATTRIBUTES_BATCH_THREADS 3 batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.attributes.value_no_xss_validation SQL_ATTRIBUTES_VALUE_NO_XSS_VALIDATION false If true attribute values will be checked for XSS vulnerability
sql.ts.batch_size SQL_TS_BATCH_SIZE 10000 Batch size for persisting timeseries inserts
sql.ts.batch_max_delay SQL_TS_BATCH_MAX_DELAY_MS 100 Max timeout for time-series entries queue polling. The value set in milliseconds
sql.ts.stats_print_interval_ms SQL_TS_BATCH_STATS_PRINT_MS 10000 Interval in milliseconds for printing timeseries insert statistic
sql.ts.batch_threads SQL_TS_BATCH_THREADS 3 batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.ts.value_no_xss_validation SQL_TS_VALUE_NO_XSS_VALIDATION false If true telemetry values will be checked for XSS vulnerability
sql.ts_latest.batch_size SQL_TS_LATEST_BATCH_SIZE 1000 Batch size for persisting latest telemetry updates
sql.ts_latest.batch_max_delay SQL_TS_LATEST_BATCH_MAX_DELAY_MS 50 Maximum timeout for latest telemetry entries queue polling. The value set in milliseconds
sql.ts_latest.stats_print_interval_ms SQL_TS_LATEST_BATCH_STATS_PRINT_MS 10000 Interval in milliseconds for printing latest telemetry updates statistic
sql.ts_latest.batch_threads SQL_TS_LATEST_BATCH_THREADS 3 batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.ts_latest.update_by_latest_ts SQL_TS_UPDATE_BY_LATEST_TIMESTAMP true Update latest values only if the timestamp of the new record is greater or equals the timestamp of the previously saved latest value. The latest values are stored separately from historical values for fast lookup from DB. Insert of historical value happens in any case
sql.events.batch_size SQL_EVENTS_BATCH_SIZE 10000 Batch size for persisting events inserts
sql.events.batch_max_delay SQL_EVENTS_BATCH_MAX_DELAY_MS 100 Max timeout for events entries queue polling. The value set in milliseconds
sql.events.stats_print_interval_ms SQL_EVENTS_BATCH_STATS_PRINT_MS 10000 Interval in milliseconds for printing events insert statistic
sql.events.batch_threads SQL_EVENTS_BATCH_THREADS 3 batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.events.partition_size SQL_EVENTS_REGULAR_PARTITION_SIZE_HOURS 168 Number of hours to partition the events. The current value corresponds to one week.
sql.events.debug_partition_size SQL_EVENTS_DEBUG_PARTITION_SIZE_HOURS 1 Number of hours to partition the debug events. The current value corresponds to one hour.
sql.edge_events.batch_size SQL_EDGE_EVENTS_BATCH_SIZE 1000 Batch size for persisting edge events inserts
sql.edge_events.batch_max_delay SQL_EDGE_EVENTS_BATCH_MAX_DELAY_MS 100 Max timeout for edge events entries queue polling. The value set in milliseconds
sql.edge_events.stats_print_interval_ms SQL_EDGE_EVENTS_BATCH_STATS_PRINT_MS 10000 Interval in milliseconds for printing edge events insert statistic
sql.edge_events.partition_size SQL_EDGE_EVENTS_PARTITION_SIZE_HOURS 168 Number of hours to partition the edge events. The current value corresponds to one week.
sql.audit_logs.partition_size SQL_AUDIT_LOGS_PARTITION_SIZE_HOURS 168 Default value - 1 week
sql.cloud_events.batch_size SQL_CLOUD_EVENTS_BATCH_SIZE 1000 Batch size for persisting cloud events inserts
sql.cloud_events.batch_max_delay SQL_CLOUD_EVENTS_BATCH_MAX_DELAY_MS 100 Max timeout for cloud events entries queue polling. The value set in milliseconds
sql.cloud_events.stats_print_interval_ms SQL_CLOUD_EVENTS_BATCH_STATS_PRINT_MS 10000 Interval in milliseconds for printing cloud events insert statistic
sql.cloud_events.partition_size SQL_CLOUD_EVENTS_PARTITION_SIZE_HOURS 24 Number of hours to partition the cloud events. The current value corresponds to one week.
sql.alarm_comments.partition_size SQL_ALARM_COMMENTS_PARTITION_SIZE_HOURS 168 Default value - 1 week
sql.notifications.partition_size SQL_NOTIFICATIONS_PARTITION_SIZE_HOURS 168 Default value - 1 week
sql.batch_sort SQL_BATCH_SORT true Specify whether to sort entities before batch update. Should be enabled for cluster mode to avoid deadlocks
sql.remove_null_chars SQL_REMOVE_NULL_CHARS true Specify whether to remove null characters from strValue of attributes and timeseries before insert
sql.log_queries SQL_LOG_QUERIES false Specify whether to log database queries and their parameters generated by the entity query repository
sql.log_queries_threshold SQL_LOG_QUERIES_THRESHOLD 5000 Threshold of slow SQL queries to log. The value set in milliseconds
sql.log_tenant_stats SQL_LOG_TENANT_STATS true Enable/Disable logging statistic information about tenants
sql.log_tenant_stats_interval_ms SQL_LOG_TENANT_STATS_INTERVAL_MS 60000 Interval in milliseconds for printing the latest statistic information about the tenant
sql.postgres.ts_key_value_partitioning SQL_POSTGRES_TS_KV_PARTITIONING MONTHS Specify partitioning size for timestamp key-value storage. Example: DAYS, MONTHS, YEARS, INDEFINITE.
sql.timescale.chunk_time_interval SQL_TIMESCALE_CHUNK_TIME_INTERVAL 604800000 Specify Interval size for new data chunks storage.
sql.timescale.batch_threads SQL_TIMESCALE_BATCH_THREADS 3 batch thread count has to be a prime number like 3 or 5 to gain perfect hash distribution
sql.ttl.ts.enabled SQL_TTL_TS_ENABLED true Enable/disable TTL (Time To Live) for timeseries records
sql.ttl.ts.execution_interval_ms SQL_TTL_TS_EXECUTION_INTERVAL 86400000 Number of milliseconds. The current value corresponds to one day
sql.ttl.ts.ts_key_value_ttl SQL_TTL_TS_TS_KEY_VALUE_TTL 0 The parameter to specify system TTL(Time To Live) value for timeseries records. Value set in seconds. 0 - records are never expired.
sql.ttl.events.enabled SQL_TTL_EVENTS_ENABLED true Enable/disable TTL (Time To Live) for event records
sql.ttl.events.execution_interval_ms SQL_TTL_EVENTS_EXECUTION_INTERVAL 3600000 Number of milliseconds (max random initial delay and fixed period).
sql.ttl.events.events_ttl SQL_TTL_EVENTS_EVENTS_TTL 0 Number of seconds. TTL is disabled by default. The accuracy of the cleanup depends on the sql.events.partition_size parameter.
sql.ttl.events.debug_events_ttl SQL_TTL_EVENTS_DEBUG_EVENTS_TTL 604800 Number of seconds. The current value corresponds to one week. The accuracy of the cleanup depends on the sql.events.debug_partition_size parameter.
sql.ttl.edge_events.enabled SQL_TTL_EDGE_EVENTS_ENABLED true Enable/disable TTL (Time To Live) for edge event records
sql.ttl.edge_events.execution_interval_ms SQL_TTL_EDGE_EVENTS_EXECUTION_INTERVAL 86400000 Number of milliseconds. The current value corresponds to one day
sql.ttl.edge_events.edge_events_ttl SQL_TTL_EDGE_EVENTS_TTL 2628000 Number of seconds. The current value corresponds to one month
sql.ttl.alarms.checking_interval SQL_ALARMS_TTL_CHECKING_INTERVAL 7200000 Number of milliseconds. The current value corresponds to two hours
sql.ttl.alarms.removal_batch_size SQL_ALARMS_TTL_REMOVAL_BATCH_SIZE 3000 To delete outdated alarms not all at once but in batches
sql.ttl.rpc.enabled SQL_TTL_RPC_ENABLED true Enable/disable TTL (Time To Live) for rpc call records
sql.ttl.rpc.checking_interval SQL_RPC_TTL_CHECKING_INTERVAL 7200000 Number of milliseconds. The current value corresponds to two hours
sql.ttl.audit_logs.enabled SQL_TTL_AUDIT_LOGS_ENABLED true Enable/disable TTL (Time To Live) for audit log records
sql.ttl.audit_logs.ttl SQL_TTL_AUDIT_LOGS_SECS 0 Disabled by default. The accuracy of the cleanup depends on the sql.audit_logs.partition_size
sql.ttl.audit_logs.checking_interval_ms SQL_TTL_AUDIT_LOGS_CHECKING_INTERVAL_MS 86400000 Default value - 1 day
sql.ttl.cloud_events.enabled SQL_TTL_CLOUD_EVENTS_ENABLED true Enable/disable TTL (Time To Live) for cloud event records
sql.ttl.cloud_events.execution_interval_ms SQL_TTL_CLOUD_EVENTS_EXECUTION_INTERVAL 86400000 Number of milliseconds. The current value corresponds to one day
sql.ttl.cloud_events.cloud_events_ttl SQL_TTL_CLOUD_EVENTS_TTL 2628000 Number of seconds. The current value corresponds to one month
sql.ttl.notifications.enabled SQL_TTL_NOTIFICATIONS_ENABLED true Enable/disable TTL (Time To Live) for notification center records
sql.ttl.notifications.ttl SQL_TTL_NOTIFICATIONS_SECS 2592000 Default value - 30 days
sql.ttl.notifications.checking_interval_ms SQL_TTL_NOTIFICATIONS_CHECKING_INTERVAL_MS 86400000 Default value - 1 day
sql.relations.max_level SQL_RELATIONS_MAX_LEVEL 50 This value has to be reasonably small to prevent infinite recursion as early as possible
sql.relations.pool_size SQL_RELATIONS_POOL_SIZE 4 This value has to be reasonably small to prevent the relation query from blocking all other DB calls
sql.relations.query_timeout SQL_RELATIONS_QUERY_TIMEOUT_SEC 20 This value has to be reasonably small to prevent the relation query from blocking all other DB calls
Parameter Env variable Default Description
spring.data.jpa.repositories.enabled _(none)_ "true" Enable/Disable the Spring Data JPA repositories support
spring.jpa.properties.jakarta.persistence.query.timeout JAVAX_PERSISTENCE_QUERY_TIMEOUT 30000 General timeout for JDBC queries
spring.jpa.open-in-view _(none)_ "false" Enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
spring.jpa.hibernate.ddl-auto _(none)_ "none" You can set a Hibernate feature that controls the DDL behavior in a more fine-grained way. The standard Hibernate property values are none, validate, update, create-drop. Spring Boot chooses a default value for you based on whether it thinks your database is embedded (default create-drop) or not (default none)
spring.datasource.driverClassName SPRING_DRIVER_CLASS_NAME org.postgresql.Driver Database driver for Spring JPA - org.postgresql.Driver
spring.datasource.url SPRING_DATASOURCE_URL jdbc:postgresql://localhost:5432/tb_edge Database connection URL
spring.datasource.username SPRING_DATASOURCE_USERNAME postgres Database user name
spring.datasource.password SPRING_DATASOURCE_PASSWORD postgres Database user password
spring.datasource.hikari.leakDetectionThreshold SPRING_DATASOURCE_HIKARI_LEAK_DETECTION_THRESHOLD 0 This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak. A value of 0 means leak detection is disabled
spring.datasource.hikari.maximumPoolSize SPRING_DATASOURCE_MAXIMUM_POOL_SIZE 16 This property increases the number of connections in the pool as demand increases. At the same time, the property ensures that the pool doesn’t grow to the point of exhausting a system’s resources, which ultimately affects an application’s performance and availability
spring.datasource.hikari.registerMbeans SPRING_DATASOURCE_HIKARI_REGISTER_MBEANS false Enable MBean to diagnose pools state via JMX
spring.datasource.events.enabled SPRING_DEDICATED_EVENTS_DATASOURCE_ENABLED false Enable dedicated datasource (a separate database) for events and audit logs. Before enabling this, make sure you have set up the following tables in the new DB: error_event, lc_event, rule_chain_debug_event, rule_node_debug_event, stats_event, audit_log
spring.datasource.events.driverClassName SPRING_EVENTS_DATASOURCE_DRIVER_CLASS_NAME org.postgresql.Driver Database driver for Spring JPA for events datasource
spring.datasource.events.url SPRING_EVENTS_DATASOURCE_URL jdbc:postgresql://localhost:5432/thingsboard_events Database connection URL for events datasource
spring.datasource.events.username SPRING_EVENTS_DATASOURCE_USERNAME postgres Database username for events datasource
spring.datasource.events.password SPRING_EVENTS_DATASOURCE_PASSWORD postgres Database user password for events datasource
spring.datasource.events.hikari.leakDetectionThreshold SPRING_EVENTS_DATASOURCE_HIKARI_LEAK_DETECTION_THRESHOLD 0 This property controls the amount of time that a connection can be out of the pool before a message is logged indicating a possible connection leak for events datasource. A value of 0 means leak detection is disabled
spring.datasource.events.hikari.maximumPoolSize SPRING_EVENTS_DATASOURCE_MAXIMUM_POOL_SIZE 4 This property increases the number of connections in the pool as demand increases for events datasource. At the same time, the property ensures that the pool doesn’t grow to the point of exhausting a system’s resources, which ultimately affects an application’s performance and availability
spring.datasource.events.hikari.registerMbeans SPRING_EVENTS_DATASOURCE_HIKARI_REGISTER_MBEANS false Enable MBean to diagnose pools state via JMX for events datasource