{"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"}],"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"],"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":"english-manuals:1fafd8c096f21a34e31cab15555194156944e1be8056c3e56abd5b227cdf8ee0","unit":"","vartype":"real"}},"Definition":{"Collection":"guc","Key":"log_transaction_sample_rate","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"log_transaction_sample_rate","SourceRevision":"english-manuals:1fafd8c096f21a34e31cab15555194156944e1be8056c3e56abd5b227cdf8ee0","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.","doc":{"anchor":"GUC-LOG-TRANSACTION-SAMPLE-RATE","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","slug":"18"},"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","unit":null,"vartype":"real"},"ManualEvidence":{"doc":{"anchor":"GUC-LOG-TRANSACTION-SAMPLE-RATE","file":"runtime-config-logging.html","lang":"en","sha256":"93c48c522a72fca19705c4c91a71e951eae653662008eee2e4a9a74a11127fde","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\u003eSets 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\u0026#39; 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.\u003c/p\u003e","SourceRevision":"english-manuals:1fafd8c096f21a34e31cab15555194156944e1be8056c3e56abd5b227cdf8ee0","ContentHash":"c879e2816ce56428f84c44659defe416d6bc1a17c7261d40bde0d42e12b517c4","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":"zh-Hans","Fallback":true,"Versions":["12","13","14","15","16","17","18","19","20"],"Locales":["en"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
