官术网_书友最值得收藏!

Tuning logging-related parameters

In this recipe, we will talk about tuning logging-related parameters.

How to do it...

The following are the logging-related parameters that usually require tuning:

  • log_line_prefix
  • log_statement
  • log_min_duration_statement

How it works...

log_line_prefix: Usually the default value related to this parameter is empty and it is not desirable. A good way to put this in context would be to use the following format:

log_line_prefix='%t:%r:%u@%d:[%p]: '

Once this format is used, every line in the log will follow this format. The following is a description of the entries:

  • %t: This is the timestamp
  • %u: This is the database username
  • %r: This is where the remote host connection is from
  • %d: This is where the database connection is to
  • %p: This is the process ID of the connection

Not all of these values will be required initially; however, at a later stage as you drill down further, they will be useful. For instance, the significance of processID becomes apparent when you are troubleshooting performance issues.

log_statement: This parameter defines which statements are logged. Statement logging is a powerful technique to find performance issues. The options for the log_statement values are as follows:

  • None: At this setting, no statement-level logging is captured.
  • DDL: When this setting is enabled, DDL statements such as CREATE, ALTER, and DROP statements are captured. This is a handy setting to find out whether there were any major changes introduced accidentally by developers or administrators alike.
  • MOD: When this setting is enabled, all the statements that modify a value will be logged. From the point of view of auditing changes, this is a handy feature. This setting is not required if your workload includes running SELECT statements or for reporting purposes.
  • ALL: When this setting is enabled, all the statements are logged. This should generally be avoided to counter the logging overhead on the server when all statements are being logged.

log_min_duration_statement: This parameter setting causes the duration of each statement to be logged if a given statement ran for at least a certain number of milliseconds. It is basically like setting a threshold and if any statement exceeds the defined thresholds, the duration of that statement is logged.

主站蜘蛛池模板: 通州区| 耒阳市| 朝阳市| 城步| 仁怀市| 贡山| 余姚市| 镇远县| 邓州市| 海盐县| 敦煌市| 曲沃县| 海伦市| 五台县| 阿坝| 新乐市| 诸城市| 张家口市| 峡江县| 馆陶县| 乡城县| 涪陵区| 阜新| 孝感市| 荣成市| 伊金霍洛旗| 墨脱县| 南川市| 泊头市| 个旧市| 赤城县| 台南市| 休宁县| 兴和县| 阳城县| 北碚区| 甘谷县| 红原县| 平远县| 南城县| 蓬莱市|