Description
log_duration records the execution time of completed statements. Without needed timing records, investigating performance degradation and load increases can be harder. This setting does not itself log statement text, and not every environment needs timings for every statement.
Potential impact
- Timing evidence needed for performance analysis may be missing.
- Unsuitable logging criteria can increase storage use and operational load.
Remediation
When duration records are needed, set log_duration to on on Flexible Server and verify actual logs. Consider settings such as log_min_duration_statement when only slow statements need logging. Manage log access, retention and collection volume together.
Examples
The before example uses retired Single Server settings. The after excerpt configures duration logging on an existing Flexible Server; the server configuration itself is omitted.
Before
resource "azurerm_postgresql_configuration" "example" {
name = "log_duration"
resource_group_name = "example_resource_group_name"
server_name = "example_server_name"
value = "OFF"
}
After
resource "azurerm_postgresql_flexible_server_configuration" "example" {
name = "log_duration"
server_id = azurerm_postgresql_flexible_server.example.id
value = "on"
}
The after example records the duration of completed statements. Configure other logging separately if statement text or audit details are needed.