# log_min_duration_statement

> Logs every completed statement whose duration reaches a threshold. It is a deterministic slow-query capture control, distinct from sampling and from statement cancellation.
---

> [!NOTE]
> **Fact — official short description:** “Sets the minimum execution time above which all statements will be logged.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `integer` | Upstream pg_settings type |
| Context | `superuser` | Settable at runtime by a superuser |
| Unit | `ms` | Raw unit |
| Range | `-1` – `2147483647` | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Reporting and Logging / When to Log | Upstream classification |
| Latest boot value | `-1` | -1 ms |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG9.0 (research boundary) |
| Present in | PG9.0–19 Beta 3 |
| Removed in | No |
| Introduction commit | Not asserted: predates the PG9.0 research boundary |
| Commit date | — |
| Discussion | — |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG9.0–19 Beta 3 | `-1` | `ms` | -1 ms |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

The value is a duration in milliseconds when no unit is written. A value of -1 disables duration-based statement logging, zero logs every completed statement, and a positive value logs statements at or above the threshold.

Statements selected by this setting are always logged rather than sampled, so it takes priority over log_min_duration_sample. Under the extended query protocol, Parse, Bind, and Execute durations can appear separately.

This parameter observes and records completed work; it does not stop slow statements. statement_timeout is the separate execution-cancellation control.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Choose a threshold from the application's latency objective and expected log volume. At high QPS, combine a meaningful hard threshold with sampled logging for the faster population. |
| OLAP | Use a higher threshold so normal long analytical work does not flood logs. Pair logs with query identifiers and workload labels so repeated reports remain actionable. |
| Small nodes | A low threshold can be useful while tuning, but watch disk use and rotation. Raise it or switch to sampling when logging becomes a measurable part of the workload. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | `100` | different | `100` |
| OLAP | `1000` | different | `1000` |
| CRIT | `100` | different | `100` |
| TINY | `100` | different | `100` |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG9.0–19 Beta 3 = 100 (dcs); OLAP: PG9.0–19 Beta 3 = 1000 (dcs); CRIT: PG9.0–19 Beta 3 = 100 (dcs); TINY: PG9.0–19 Beta 3 = 100 (dcs). Advice, pending human review — Editorial hypothesis, pending maintainer review: Pigsty opts into deterministic slow-query evidence, while OLAP uses a looser threshold to accommodate naturally longer analytical statements.

## Common pitfalls {#common-pitfalls}

- Low thresholds on high-throughput systems can create extreme log volume and I/O.
- SQL text can contain sensitive literals and must be protected like application data.
- It logs slow statements but does not cancel them; use statement_timeout for that goal.
- Extended-protocol phases may be logged separately and need session or PID correlation.
- Interactions with log_statement, sampling, and log_line_prefix can confuse duplicate or fragmented entries.

## Related parameters {#related-parameters}

[`log_min_duration_sample`](/parameters/log-min-duration-sample/) · [`log_statement_sample_rate`](/parameters/log-statement-sample-rate/) · [`log_statement`](/parameters/log-statement/) · [`log_duration`](/parameters/log-duration/) · [`log_line_prefix`](/parameters/log-line-prefix/) · [`statement_timeout`](/parameters/statement-timeout/)

## References {#references}

- [PostgreSQL 19 Beta 3 — log_min_duration_statement](https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-MIN-DURATION-STATEMENT)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
