{"Entry":{"collection":"guc","key":"log_transaction_sample_rate","name":"log_transaction_sample_rate","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Reporting and Logging / When to Log","category_zh":"","changed_in":["14"],"changes":[{"documentation_changed":false,"fields":{},"from":"11","status":"added","to":"12"},{"documentation_changed":true,"fields":{},"from":"12","status":"changed","to":"13"},{"documentation_changed":false,"fields":{"extra_desc":{"from":"Logs all statements from a fraction of transactions. Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions).","to":"Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions)."},"short_desc":{"from":"Set the fraction of transactions to log for new transactions.","to":"Sets the fraction of transactions from which to log all statements."}},"from":"13","status":"changed","to":"14"},{"documentation_changed":true,"fields":{},"from":"14","status":"changed","to":"15"}],"content_hash":"1d8e8024f938030dd2ecdc7f6696f488c116dcd0b0d05907483da1944a6e5b60","context":"","default_changed_in":[],"default_history":[{"from":"12","to":"19","value":"0"}],"derived_content_hash":"f8d01f4b5c24c11b2558637278c831a940ac02b989337d00115308a0642537df","documentation_refresh":{"batch":"20261113","original_source_rev":"wiki-repair-20261023:549803b3a0fea80920b24dee7ae43433c9093cb5270bea1aa182eab5d5b4c3c2","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"editorial":{"advice":{"olap":"Analytical jobs can justify richer log_transaction_sample_rate telemetry, but account for long statements, large bind values, and bursty completion patterns in the log pipeline.","oltp":"Tune log_transaction_sample_rate against an explicit observability question and a measured log-volume budget. Prefer selective thresholds, sampling, or role-level overrides over indiscriminate capture.","small":"Keep log_transaction_sample_rate useful but bounded: verify disk, collector, retention, and redaction capacity before increasing detail or frequency."},"mechanism":["log_transaction_sample_rate sets the fraction of transactions from which to log all statements. Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions). A sampled transaction logs every statement, preserving transaction context but potentially creating bursts from long or chatty transactions.","log_transaction_sample_rate is a SUPERUSER-context setting. Superuser or a role granted the appropriate SET privilege can change it for a session, while ALTER ROLE or ALTER DATABASE can establish a default for future sessions.","It changes emitted diagnostic data rather than query semantics, but volume, sensitive content, log_line_prefix, destinations, collector throughput, and retention determine operational cost and usefulness."],"pitfalls":["Changing log_transaction_sample_rate in one session and assuming role defaults, database defaults, or other pooled sessions changed with it.","Enabling richer logging without budgeting collector throughput, storage, retention, and downstream query cost.","Writing SQL text, bind values, identities, or host data without a redaction and access-control policy.","Underestimating bursts when one sampled, chatty transaction causes every statement to be logged."],"references":[{"title":"PostgreSQL 19 Beta 4: log_transaction_sample_rate","url":"https://www.postgresql.org/docs/19/runtime-config-logging.html#GUC-LOG-TRANSACTION-SAMPLE-RATE"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["log_min_messages","log_min_error_statement","log_min_duration_statement","log_min_duration_sample","log_statement_sample_rate"],"summary":"log_transaction_sample_rate is the PostgreSQL setting that defines the fraction of transactions from which to log all statements."},"enumvals":[],"first_version":"12","group":"Reporting and Logging","group_slug":"logging","imported_at":"2026-09-30T00:40:57.448723+08:00","intro_commit":{"authored_at":"2019-04-03T18:43:59-03:00","discussion":[],"hash":"799e220346f1387e823a4dbdc3b1c8c3cdc5c3e0","subject":"Log all statements from a sample of transactions","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=799e220346f1387e823a4dbdc3b1c8c3cdc5c3e0"},"key":"log_transaction_sample_rate","last_version":"20","max_val":"","min_val":"","name":"log_transaction_sample_rate","position":255,"present_in":["12","13","14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"english-manuals:1fafd8c096f21a34e31cab15555194156944e1be8056c3e56abd5b227cdf8ee0","receipt_sha256":"8d2340bdb71dc13c896306ac930965eb2041b99dc6db7ae8a5f64e15ffccf9d9","repair":"wiki-repair-20261023"},"short_desc":"Sets the fraction of transactions whose statements are all logged, in addition to statements logged for other reasons.","short_desc_zh":"","source_rev":"wiki-repair-20261023:549803b3a0fea80920b24dee7ae43433c9093cb5270bea1aa182eab5d5b4c3c2","unit":"","vartype":"real"}},"Definition":{"Collection":"guc","Key":"log_transaction_sample_rate","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_transaction_sample_rate","SourceRevision":"wiki-repair-20261023:549803b3a0fea80920b24dee7ae43433c9093cb5270bea1aa182eab5d5b4c3c2","Facts":{"boot_val":"0","category":"Reporting and Logging / When to Log","context":"superuser","description":"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. 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 and users with the appropriate SET privilege can change this setting. Note Like all statement-logging options, this option can add significant overhead.","description_zh":"设置需要记录全部语句的事务比例，这些记录是在因其他原因记录的语句之外额外进行的。它适用于每个新事务，无论其语句的持续时间如何。采样是随机的，例如 0.1 表示任何给定事务被记录的统计概率是十分之一。log_transaction_sample_rate 可以帮助构建事务样本。默认值为 0，表示不记录任何额外事务的语句。将其设置为 1 会记录所有事务的所有语句。只有超级用户和具有适当 SET 权限的用户才能更改此设置。 注意 就像所有的语句-日志选项一样，这个选项可能会增加大量开销。","description_zh_html":"\u003cp\u003e\n         设置需要记录全部语句的事务比例，这些记录是在因其他原因记录的语句之外额外进行的。它适用于每个新事务，无论其语句的持续时间如何。采样是随机的，例如 \u003ccode class=\"literal\"\u003e0.1\u003c/code\u003e 表示任何给定事务被记录的统计概率是十分之一。\u003ccode class=\"varname\"\u003elog_transaction_sample_rate\u003c/code\u003e 可以帮助构建事务样本。默认值为 \u003ccode class=\"literal\"\u003e0\u003c/code\u003e，表示不记录任何额外事务的语句。将其设置为 \u003ccode class=\"literal\"\u003e1\u003c/code\u003e 会记录所有事务的所有语句。只有超级用户和具有适当 \u003ccode class=\"literal\"\u003eSET\u003c/code\u003e 权限的用户才能更改此设置。\n        \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003e注意\u003c/h3\u003e\u003cp\u003e\n         就像所有的语句-日志选项一样，这个选项可能会增加大量开销。\n        \u003c/p\u003e\u003c/div\u003e","doc":{"anchor":"GUC-LOG-TRANSACTION-SAMPLE-RATE","file":"runtime-config-logging.html","lang":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","slug":"18"},"doc_html":"\u003cp\u003e\n         Sets the fraction of transactions whose statements are all logged,\n         in addition to statements logged for other reasons.  It applies to\n         each new transaction regardless of its statements' durations.\n         Sampling is stochastic, for example \u003ccode class=\"literal\"\u003e0.1\u003c/code\u003e means\n         there is statistically one chance in ten that any given transaction\n         will be logged.\n         \u003ccode class=\"varname\"\u003elog_transaction_sample_rate\u003c/code\u003e can be helpful to\n         construct a sample of transactions.\n         The default is \u003ccode class=\"literal\"\u003e0\u003c/code\u003e, meaning not to log\n         statements from any additional transactions.  Setting this\n         to \u003ccode class=\"literal\"\u003e1\u003c/code\u003e logs all statements of all transactions.\n         Only superusers and users with the appropriate \u003ccode class=\"literal\"\u003eSET\u003c/code\u003e\n         privilege can change this setting.\n        \u003c/p\u003e\u003cdiv class=\"note\"\u003e\u003ch3 class=\"title\"\u003eNote\u003c/h3\u003e\u003cp\u003e\n         Like all statement-logging options, this option can add significant\n         overhead.\n        \u003c/p\u003e\u003c/div\u003e","doc_same_as":"","documentation_revision":{"inputs":[{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","version":"18.7"},{"file":"runtime-config-logging.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"68c010254e1859ec0b76f06a563babd51a6c38997f1242e35e4c6b649724b1cb","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"},"documented":true,"enumvals":null,"extra_desc":"Use a value between 0.0 (never log) and 1.0 (log all statements for all transactions).","lang":"en","max_val":"1","metadata_version":"18","min_val":"0","name":"log_transaction_sample_rate","short_desc":"Sets the fraction of transactions from which to log all statements.","source":"pg-settings-source-snapshot","translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/runtime-config-logging.html","sha256":"a322f5293f10e348b5fc5dca98fdb6af52462723a215b8701c3b9d933e2933b4"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"unit":null,"vartype":"real","zh_from":"same-version-manual"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-TRANSACTION-SAMPLE-RATE","file":"runtime-config-logging.html","lang":"en","sha256":"278d913b9c0f735c5cd7b35fd7205826bbd9c449805370d2dbe54105c0ed1d88","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"log_transaction_sample_rate","SourceDatabase":"center","Version":"18","Locale":"en","Title":"log_transaction_sample_rate","Summary":"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. 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 and users with the appropriate SET privilege can change this setting. Note Like all statement-logging options, this option can add significant overhead.","BodyHTML":"\u003cp\u003e\n         Sets the fraction of transactions whose statements are all logged,\n         in addition to statements logged for other reasons.  It applies to\n         each new transaction regardless of its statements\u0026#39; durations.\n         Sampling is stochastic, for example \u003ccode\u003e0.1\u003c/code\u003e means\n         there is statistically one chance in ten that any given transaction\n         will be logged.\n         \u003ccode\u003elog_transaction_sample_rate\u003c/code\u003e can be helpful to\n         construct a sample of transactions.\n         The default is \u003ccode\u003e0\u003c/code\u003e, meaning not to log\n         statements from any additional transactions.  Setting this\n         to \u003ccode\u003e1\u003c/code\u003e logs all statements of all transactions.\n         Only superusers and users with the appropriate \u003ccode\u003eSET\u003c/code\u003e\n         privilege can change this setting.\n        \u003c/p\u003e\u003cdiv\u003e\u003ch3\u003eNote\u003c/h3\u003e\u003cp\u003e\n         Like all statement-logging options, this option can add significant\n         overhead.\n        \u003c/p\u003e\u003c/div\u003e","SourceRevision":"wiki-repair-20261023:549803b3a0fea80920b24dee7ae43433c9093cb5270bea1aa182eab5d5b4c3c2","ContentHash":"6e67e7ca6feea8b149503a920fd472d79a1310dd45cb69e515bd4faf4e531ea0","Payload":{"description":"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. 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 and users with the appropriate SET privilege can change this setting. Note Like all statement-logging options, this option can add significant overhead."}},"RequestedLocale":"en","Fallback":false,"Versions":["12","13","14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
