log_min_duration_statement
The log_min_duration_statement
parameter controls the minimum amount of time,
in milliseconds, that a SQL statement runs before it is logged.
This parameter helps you identify long-running queries that might cause performance issues. You can set it to a threshold value (a runtime that is considered too long for a specific workload) to capture queries that exceed that threshold and identify potential performance bottlenecks. For an example use case, see Using logging parameters to capture bind variables later in this guide.
AWS CLI syntax
The following command changes log_min_duration_statement
for a specific DB
parameter group. This change applies to all instances or clusters that use the parameter
group.
# Modify log_min_duration_statement on a DB parameter group aws rds modify-db-parameter-group \ --db-parameter-group-name <parameter_group_name> \ --parameters "ParameterName=log_min_duration_statement,ParameterValue=<new_value>,ApplyMethod=immediate" # Modify log_ min_duration_statement on a DB cluster parameter group aws rds modify-db-cluster-parameter-group \ --db-cluster-parameter-group-name <parameter_group_name> \ --parameters "ParameterName=log_min_duration_statement,ParameterValue=<new_value>,ApplyMethod=immediate"
Type: Dynamic (changes are applied immediately if you set
ApplyMethod=immediate
)
Default value: 1 (disabled, which is the PostgreSQL engine default)
Example
The following command logs any statement that takes longer than 100 milliseconds to run:
aws rds modify-db-parameter-group \ --db-parameter-group-name <parameter_group_name> \ --parameters "ParameterName=log_min_duration_statement,ParameterValue=100,ApplyMethod=immediate"