diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index c1128f89ec..371d7838fb 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -5984,13 +5984,13 @@ local0.* /var/log/postgresql Causes the duration of each completed statement to be logged if the statement ran for at least the specified amount of time. - If this value is specified without units, it is taken as milliseconds. - Setting this to zero prints all statement durations. - Minus-one (the default) disables logging statement durations. For example, if you set it to 250ms then all SQL statements that run 250ms or longer will be logged. Enabling this parameter can be helpful in tracking down unoptimized queries in your applications. + If this value is specified without units, it is taken as milliseconds. + Setting this to zero prints all statement durations. + Minus-one (the default) disables logging statement durations. Only superusers can change this setting. @@ -6030,49 +6030,39 @@ local0.* /var/log/postgresql - Allows to sample the logging of the duration of each completed - statement if the statement ran for at least the specified amount of - time. If this value is specified without units, it is taken as milliseconds. + Allows sampling the duration of completed statements that ran for + at least the specified amount of time. This produces the same + kind of log entries as + , but only for a + subset of the executed statements, with sample rate controlled by + . + For example, if you set it to 100ms then all + SQL statements that run 100ms or longer will be considered for + sampling. Enabling this parameter can be helpful when the + traffic is too high to log all queries. + If this value is specified without units, it is taken as milliseconds. Setting this to zero samples all statement durations. Minus-one (the default) disables sampling statement durations. - For example, if you set it to 250ms - then all SQL statements that run 250ms or longer will be considered - for sampling, with sample rate is controlled by . - Enabling this parameter can be helpful when the traffic too high to - sample all queries. Only superusers can change this setting. - This option has lower priority than , - meaning that statements with durations exceeding - are not subject to sampling and are always logged. + This setting has lower priority + than log_min_duration_statement, meaning that + statements with durations + exceeding log_min_duration_statement are not + subject to sampling and are always logged. - For clients using extended query protocol, durations of the Parse, - Bind, and Execute steps are logged independently. + Other notes for log_min_duration_statement + apply also to this setting. - - - - When using this option together with - , - the text of statements that are logged because of - log_statement will not be repeated in the - duration log message. - If you are not using syslog, it is recommended - that you log the PID or session ID using - - so that you can link the statement message to the later - duration message using the process ID or session ID. - - - log_statement_sample_rate (real) + log_statement_sample_rate (floating point) log_statement_sample_rate configuration parameter @@ -6080,43 +6070,40 @@ local0.* /var/log/postgresql Determines the fraction of statements with duration exceeding - to be logged. - This is a statistical parameter, for example 0.5 - means there is statistically one in two chances to log the statement. - The default is 1.0, meaning log all such + that will be logged. + Sampling is stochastic, for example 0.5 means + there is statistically one chance in two that any given statement + will be logged. + The default is 1.0, meaning to log all sampled statements. - Setting this to zero disables sampling logging, same as setting + Setting this to zero disables sampled statement-duration logging, + the same as setting log_min_duration_sample to -1. - log_statement_sample_rate is helpful when the - traffic is too high to log all queries. Only superusers can change this setting. - - - Like all statement-logging options, this option can add significant - overhead. - - - log_transaction_sample_rate (real) + log_transaction_sample_rate (floating point) log_transaction_sample_rate configuration parameter - Set the fraction of transactions whose statements are all logged, + Sets the fraction of transactions whose statements are all logged, in addition to statements logged for other reasons. It applies to each new transaction regardless of its statements' durations. - The default is 0, meaning not to log statements - from any additional transaction. Setting this to 1 - logs all statements for all transactions. - log_transaction_sample_rate is helpful to track a - sample of transaction. + Sampling is stochastic, for example 0.1 means + there is statistically one chance in ten that any given transaction + will be logged. + log_transaction_sample_rate can be helpful to + construct a sample of transactions. + The default is 0, meaning not to log + statements from any additional transactions. Setting this + to 1 logs all statements of all transactions. Only superusers can change this setting. @@ -6632,9 +6619,9 @@ log_line_prefix = '%m [%p] %q%u@%d/%a ' Controls whether bind parameters are logged when a statement is logged as a result of . - It adds some overhead, as postgres will compute and store textual - representations of parameter values in memory for all statements, - even if they eventually do not get logged. + It adds some overhead, as PostgreSQL will + compute and store textual representations of parameter values in + memory for all statements, even if they eventually do not get logged. This setting has no effect on statements logged due to or settings, as they are always logged diff --git a/src/backend/nodes/params.c b/src/backend/nodes/params.c index b28ec3b6ce..a57f9eea76 100644 --- a/src/backend/nodes/params.c +++ b/src/backend/nodes/params.c @@ -262,16 +262,16 @@ RestoreParamList(char **start_address) /* * BuildParamLogString - * Return a string that represent the parameter list, for logging. + * Return a string that represents the parameter list, for logging. * * If caller already knows textual representations for some parameters, it can * pass an array of exactly params->numParams values as knownTextValues, which * can contain NULLs for any unknown individual values. NULL can be given if * no parameters are known. * - * If maxlen is not zero, that's the maximum number of characters of the - * input string printed; an ellipsis is added if more characters exist. - * (Added quotes are not considered.) + * If maxlen is not zero, that's the maximum number of bytes of any one + * parameter value to be printed; an ellipsis is added if the string is + * longer. (Added quotes are not considered in this calculation.) */ char * BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen) @@ -282,7 +282,8 @@ BuildParamLogString(ParamListInfo params, char **knownTextValues, int maxlen) /* * NB: think not of returning params->paramValuesStr! It may have been - * generated with a different maxlen, and so unsuitable. + * generated with a different maxlen, and so be unsuitable. Besides that, + * this is the function used to create that string. */ /* diff --git a/src/backend/utils/mb/stringinfo_mb.c b/src/backend/utils/mb/stringinfo_mb.c index c153b77007..791a667dae 100644 --- a/src/backend/utils/mb/stringinfo_mb.c +++ b/src/backend/utils/mb/stringinfo_mb.c @@ -26,7 +26,7 @@ /* * appendStringInfoStringQuoted * - * Append up to maxlen characters from s to str, or the whole input string if + * Append up to maxlen bytes from s to str, or the whole input string if * maxlen <= 0, adding single quotes around it and doubling all single quotes. * Add an ellipsis if the copy is incomplete. */