Skip to content

Commit 476ed4d

Browse files
committed
docs: track CNS-136's revised statement logging defaults
CNS-136 changed the chart sample rate default from 0.1 to 0.99, matching Cloud, and clarified that the sample rate is not what bounds how much query history stores. Update the documented defaults and invert the tuning guidance to match: statement_logging_target_data_rate is the parameter that bounds storage growth, so that is the one to lower on instances with limited storage. Lowering the sample rate only reduces environmentd CPU overhead and makes the history less representative, without lowering the ceiling. CNS-139
1 parent d3e111a commit 476ed4d

1 file changed

Lines changed: 63 additions & 62 deletions

File tree

doc/user/content/self-managed-deployments/query-history.md

Lines changed: 63 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,14 @@ To see query history in the Console, connect as a Materialize *superuser* or as
2626
a user granted the [`mz_monitor`
2727
role](/security/appendix/appendix-built-in-roles/#system-catalog-roles).
2828

29-
## Default sample rate
29+
## Defaults
3030

31-
The Materialize operator Helm chart sets the
32-
`operator.args.statementLoggingMaxSampleRate` value to `0.1`, so roughly 10% of
33-
statement executions are sampled.
34-
35-
This value is lower than `environmentd`'s own default of `0.99`. Statement
36-
logging costs CPU on `environmentd` and storage for the retained history, and
37-
that overhead is most noticeable on the small instances typical of self-managed
38-
deployments, so the chart samples a fraction of statements instead.
31+
The Materialize operator Helm chart sets
32+
`operator.args.statementLoggingMaxSampleRate` to `0.99`, and leaves
33+
`operator.args.statementLoggingTargetDataRate` unset so that `environmentd`'s
34+
own default of 2071 bytes per second applies. Both are the values Materialize
35+
Cloud runs at, so query history in a self-managed deployment behaves the same as
36+
in Cloud out of the box.
3937

4038
The rate that actually applies to a statement is the smaller of two parameters:
4139

@@ -47,17 +45,16 @@ The rate that actually applies to a statement is the smaller of two parameters:
4745
Because the system parameter is a cap, lowering it reduces logging for every
4846
session regardless of what individual sessions request.
4947

50-
Sampling is not the only limit. Materialize also throttles statement logging to
51-
a sustained byte rate, `statement_logging_target_data_rate`, which defaults to
52-
2071 bytes per second. Sampled executions beyond that budget are dropped, so a
53-
sample rate of `1.0` does not guarantee that every statement is recorded. On
54-
busy instances this byte rate, rather than the sample rate, is what actually
55-
bounds how much history you collect.
48+
Sampling is not the only limit, and it is not the one that bounds volume.
49+
Materialize also throttles statement logging to a sustained byte rate,
50+
`statement_logging_target_data_rate`, and drops sampled executions that would
51+
exceed it. So a sample rate of `1.0` does not guarantee every statement is
52+
recorded, and on a busy instance the byte rate is what determines how much
53+
history you actually accumulate.
5654

5755
{{< note >}}
58-
Unlike Materialize Cloud, self-managed deployments log statements issued by the
59-
`mz_system` user by default, because the chart enables
60-
`enableInternalStatementLogging`. Internal activity, including the Console's own
56+
The chart also enables `enableInternalStatementLogging`, so statements issued by
57+
the `mz_system` user are logged. Internal activity, including the Console's own
6158
catalog queries, is sampled alongside your workload and counts toward the cost
6259
described below.
6360
{{< /note >}}
@@ -68,43 +65,45 @@ Two parameters bound how much query history you collect:
6865

6966
| Parameter | Chart value | Bounds |
7067
|-----------|-------------|--------|
71-
| `statement_logging_max_sample_rate` | `operator.args.statementLoggingMaxSampleRate` (`0.1`) | The fraction of executions considered for logging. |
72-
| `statement_logging_target_data_rate` | `operator.args.statementLoggingTargetDataRate` (unset) | The sustained bytes per second written, 2071 by default. |
68+
| `statement_logging_max_sample_rate` | `operator.args.statementLoggingMaxSampleRate` (`0.99`) | The fraction of executions considered for logging. |
69+
| `statement_logging_target_data_rate` | `operator.args.statementLoggingTargetDataRate` (unset, so 2071) | The sustained bytes per second written. Must be greater than 0. |
7370

74-
Raise the sample rate for more representative history. Lower the data rate to
75-
hold storage growth down. Each can be set either through the Helm chart or as a
76-
system parameter, and those two paths interact, so read the note on precedence
77-
below before picking one.
71+
The two are not interchangeable. Lower the data rate to hold storage growth
72+
down. Lowering the sample rate instead makes query history less representative
73+
without lowering the ceiling on what statement logging stores, because the byte
74+
rate is already the binding limit. Each can be set either through the Helm chart
75+
or as a system parameter, and those two paths interact, so read the note on
76+
precedence below before picking one.
7877

7978
### Using the Helm chart
8079

81-
Set `operator.args.statementLoggingMaxSampleRate` when installing or upgrading
82-
the operator:
80+
Set either value when installing or upgrading the operator. For example, to
81+
halve how fast query history grows:
8382

8483
```shell
8584
helm upgrade my-materialize-operator materialize/materialize-operator \
86-
--set operator.args.statementLoggingMaxSampleRate=0.5
85+
--set operator.args.statementLoggingTargetDataRate=1035
8786
```
8887

8988
Or, in your `values.yaml`:
9089

9190
```yaml
9291
operator:
9392
args:
94-
statementLoggingMaxSampleRate: 0.5
95-
statementLoggingTargetDataRate: 4096
93+
statementLoggingMaxSampleRate: 0.99
94+
statementLoggingTargetDataRate: 1035
9695
```
9796
9897
Setting `statementLoggingMaxSampleRate` to `0` disables statement logging
99-
entirely. Already-logged
100-
statements remain visible until they age out of the 24-hour window. Setting the
101-
value to `null` inherits `environmentd`'s default of `0.99`.
102-
`statementLoggingTargetDataRate` is unset by default, which inherits
103-
`environmentd`'s default of 2071 bytes per second.
104-
105-
The operator passes this value to `environmentd` as the *default* for
106-
`statement_logging_max_sample_rate`, so it only takes effect when `environmentd`
107-
restarts. Upgrading the operator does not by itself roll out your Materialize
98+
entirely. Already-logged statements remain visible until they age out of the
99+
24-hour window. Setting either value to `null` inherits `environmentd`'s own
100+
default, `0.99` for the sample rate and 2071 bytes per second for the data rate.
101+
The data rate must be greater than 0.
102+
103+
The operator passes these values to `environmentd` as the *defaults* for
104+
`statement_logging_max_sample_rate` and
105+
`statement_logging_target_data_rate`, so they only take effect when
106+
`environmentd` restarts. Upgrading the operator does not by itself roll out your Materialize
108107
instances: you also need to request a rollout, as described in [modifying the
109108
custom
110109
resource](/self-managed-deployments/#modifying-the-custom-resource). For the
@@ -113,9 +112,9 @@ Configuration](/self-managed-deployments/operator-configuration/).
113112

114113
### Using system parameters
115114

116-
Because the chart value is only a default, you can override it at runtime
117-
without a rollout, either through the `system-params.json` ConfigMap described
118-
in [Configuring System
115+
Because the chart values are only defaults, you can override either at runtime
116+
without a rollout, through the `system-params.json` ConfigMap described in
117+
[Configuring System
119118
Parameters](/self-managed-deployments/configuration-system-parameters/):
120119

121120
```yaml
@@ -127,22 +126,22 @@ metadata:
127126
data:
128127
system-params.json: |
129128
{
130-
"statement_logging_max_sample_rate": 0.5
129+
"statement_logging_target_data_rate": 1035
131130
}
132131
```
133132

134133
Or with [`ALTER SYSTEM SET`](/sql/alter-system-set/), connected as the
135134
`mz_system` user:
136135

137136
```mzsql
138-
ALTER SYSTEM SET statement_logging_max_sample_rate = 0.5;
137+
ALTER SYSTEM SET statement_logging_target_data_rate = 1035;
139138
```
140139

141140
{{< note >}}
142141
A value set through the ConfigMap or `ALTER SYSTEM SET` is stored in the catalog
143142
and takes precedence over the Helm chart value, which is only a default. While
144-
such an override is in place, editing
145-
`operator.args.statementLoggingMaxSampleRate` has no effect.
143+
such an override is in place, editing the corresponding chart value has no
144+
effect.
146145

147146
To go back to the chart-provided value, first remove the parameter from the
148147
ConfigMap, then run [`ALTER SYSTEM
@@ -152,32 +151,34 @@ while it is still in the ConfigMap is also not enough, because the sync loop
152151
reapplies it.
153152
{{< /note >}}
154153

155-
To check the rate currently in effect:
154+
To check the values currently in effect:
156155

157156
```mzsql
158157
SHOW statement_logging_max_sample_rate;
158+
SHOW statement_logging_target_data_rate;
159159
```
160160

161-
## Cost of raising the sample rate
161+
## Cost of statement logging
162162

163-
Raising the sample rate gives more complete query history at the cost of:
163+
Statement logging has two distinct costs, and each is governed by a different
164+
parameter:
164165

165-
- **CPU on `environmentd`**: every logged execution is prepared and written by
166-
the control plane, so the overhead scales with your statement throughput, not
167-
with your data volume. Instances serving many short queries pay the most.
166+
- **CPU on `environmentd`**, governed by the sample rate. Every logged execution
167+
is prepared and written by the control plane, so the overhead scales with your
168+
statement throughput, not with your data volume. Instances serving many short
169+
queries pay the most.
168170

169-
- **Storage**: logged statements, including their SQL text, are retained in the
170-
system catalog and consume space in your blob storage and metadata backend.
171+
- **Storage**, governed by the target data rate. Logged statements, including
172+
their SQL text, consume space in your blob storage and metadata backend.
171173
Although `mz_recent_activity_log` only surfaces the last 24 hours, the
172-
underlying statement history collections are not truncated, so their footprint
173-
grows for the lifetime of the instance.
174-
175-
Workloads dominated by a high rate of small, fast queries are the ones where a
176-
high sample rate is most likely to be felt. If you raise the rate, do it
177-
incrementally and watch `environmentd` CPU utilization and your storage
178-
footprint. Because the byte rate is what bounds sustained growth, lowering
179-
`statement_logging_target_data_rate` is the more direct control if your concern
180-
is storage rather than sampling fidelity.
174+
underlying statement history collections are never truncated, so their
175+
footprint grows for the lifetime of the instance.
176+
177+
That second point is the one to plan around: query history is not a fixed-size
178+
buffer, and its growth rate is set by `statement_logging_target_data_rate`. On
179+
an instance with limited storage, lower that parameter. Reach for the sample
180+
rate only when you want to reduce `environmentd` CPU overhead, and expect less
181+
representative history in exchange.
181182

182183
## See also
183184

0 commit comments

Comments
 (0)