diff --git a/config/config.md b/config/config.md
index 46d7b440c1..b600ec0de6 100644
--- a/config/config.md
+++ b/config/config.md
@@ -402,8 +402,8 @@
| `event_recorder` | -- | -- | Configuration options for the event recorder. |
| `event_recorder.ttl` | String | `90d` | TTL for the events table that will be used to store the events. Default is `90d`. |
| `stats_persistence` | -- | -- | Configuration options for the stats persistence. |
-| `stats_persistence.ttl` | String | `30d` | TTL for the stats table that will be used to store the stats. Default is `30d`.
Set to `0s` to disable stats persistence. |
-| `stats_persistence.interval` | String | `60s` | The interval to persist the stats. Default is `60s`.
The minimum value is `60s`, if the value is less than `60s`, it will be overridden to `60s`. |
+| `stats_persistence.ttl` | String | `0s` | TTL for the stats table that will be used to store the stats.
Set to `0s` to disable stats persistence.
Default is `0s`.
If you want to enable stats persistence, set the TTL to a value greater than 0.
It is recommended to set a small value, e.g., `3h`. |
+| `stats_persistence.interval` | String | `10m` | The interval to persist the stats. Default is `10m`.
The minimum value is `10m`, if the value is less than `10m`, it will be overridden to `10m`. |
| `logging` | -- | -- | The logging options. |
| `logging.dir` | String | `./greptimedb_data/logs` | The directory to store the log files. If set to empty, logs will not be written to files. |
| `logging.level` | String | Unset | The log level. Can be `info`/`debug`/`warn`/`error`. |
diff --git a/config/metasrv.example.toml b/config/metasrv.example.toml
index 736f035949..cf40ddc0b1 100644
--- a/config/metasrv.example.toml
+++ b/config/metasrv.example.toml
@@ -274,12 +274,15 @@ ttl = "90d"
## Configuration options for the stats persistence.
[stats_persistence]
-## TTL for the stats table that will be used to store the stats. Default is `30d`.
+## TTL for the stats table that will be used to store the stats.
## Set to `0s` to disable stats persistence.
-ttl = "30d"
-## The interval to persist the stats. Default is `60s`.
-## The minimum value is `60s`, if the value is less than `60s`, it will be overridden to `60s`.
-interval = "60s"
+## Default is `0s`.
+## If you want to enable stats persistence, set the TTL to a value greater than 0.
+## It is recommended to set a small value, e.g., `3h`.
+ttl = "0s"
+## The interval to persist the stats. Default is `10m`.
+## The minimum value is `10m`, if the value is less than `10m`, it will be overridden to `10m`.
+interval = "10m"
## The logging options.
[logging]
diff --git a/src/meta-srv/src/handler/persist_stats_handler.rs b/src/meta-srv/src/handler/persist_stats_handler.rs
index e99a65e437..2b070ca59d 100644
--- a/src/meta-srv/src/handler/persist_stats_handler.rs
+++ b/src/meta-srv/src/handler/persist_stats_handler.rs
@@ -152,13 +152,9 @@ fn align_ts(ts: i64, interval: Duration) -> i64 {
impl PersistStatsHandler {
/// Creates a new [`PersistStatsHandler`].
pub fn new(inserter: Box, mut persist_interval: Duration) -> Self {
- if persist_interval < Duration::from_secs(60) {
- warn!("persist_interval is less than 60 seconds, set to 60 seconds");
- persist_interval = Duration::from_secs(60);
- }
- if persist_interval.as_millis() == 0 {
- warn!("persist_interval as milliseconds is zero, set to 60 second");
- persist_interval = Duration::from_secs(60);
+ if persist_interval < Duration::from_mins(10) {
+ warn!("persist_interval is less than 10 minutes, set to 10 minutes");
+ persist_interval = Duration::from_mins(10);
}
Self {
diff --git a/src/meta-srv/src/lib.rs b/src/meta-srv/src/lib.rs
index aef561e1dc..7123598ec4 100644
--- a/src/meta-srv/src/lib.rs
+++ b/src/meta-srv/src/lib.rs
@@ -16,6 +16,7 @@
#![feature(assert_matches)]
#![feature(hash_set_entry)]
#![feature(let_chains)]
+#![feature(duration_constructors_lite)]
#![feature(duration_constructors)]
pub mod bootstrap;
diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs
index 3f44904d70..bdd6b2e815 100644
--- a/src/meta-srv/src/metasrv.rs
+++ b/src/meta-srv/src/metasrv.rs
@@ -114,8 +114,8 @@ pub struct StatsPersistenceOptions {
impl Default for StatsPersistenceOptions {
fn default() -> Self {
Self {
- ttl: Duration::from_days(30),
- interval: Duration::from_secs(60),
+ ttl: Duration::ZERO,
+ interval: Duration::from_mins(10),
}
}
}