{"Entry":{"collection":"guc","key":"compute_query_id","name":"compute_query_id","aliases":[],"metadata":{"baseline":false,"boot_human":"Not specified","boot_val":null,"category":"Statistics / Monitoring","category_zh":"","changed_in":["15"],"changes":[{"documentation_changed":false,"fields":{},"from":"13","status":"added","to":"14"},{"documentation_changed":false,"fields":{"short_desc":{"from":"Compute query identifiers.","to":"Enables in-core computation of query identifiers."}},"from":"14","status":"changed","to":"15"}],"content_hash":"fc93cd07f68938ba15f6569ca3e799fd3442bc86057ddd3042aa1c3c331465bb","context":"","default_changed_in":[],"default_history":[{"from":"14","to":"19","value":"auto"}],"editorial":{"advice":{"olap":"auto or on can make long analytical statements easier to correlate across pg_stat_activity, EXPLAIN, and logs. The cost is query-tree normalization and hashing, not clock reads; compare planning CPU on workloads with very large statements.","oltp":"Use auto when pg_stat_statements or another module should request the in-core identifier, and use on only when logs, EXPLAIN, or monitoring require IDs without such a module. Measure query-normalization overhead at peak parse/plan rates.","small":"Keep auto unless an external query-ID provider requires off. regress is for stable regression output, not a smaller production setting, and off can remove IDs required by pg_stat_statements."},"mechanism":["compute_query_id controls PostgreSQL's in-core normalized query identifier. The identifier can appear in pg_stat_activity, EXPLAIN, and logs, and is required by pg_stat_statements unless another module computes one.","auto lets a module request in-core computation, on always computes, off prevents it, and regress behaves like auto while suppressing the ID in EXPLAIN for stable regression output.","Only one provider should compute the identifier. An extension with an alternative algorithm must disable the in-core implementation and detect conflicts rather than silently publishing two incompatible IDs. Its superuser context permits an authorized session change without a server restart."],"pitfalls":["Enabling the in-core provider while an extension also attempts to compute a different query identifier.","Setting off and silently losing IDs required by pg_stat_statements, logs, or correlation tooling.","Treating regress as a production optimization rather than a test-output mode.","Using query IDs as stable cross-major-version or cryptographic identifiers."],"references":[{"title":"PostgreSQL 19 Beta 4: compute_query_id","url":"https://www.postgresql.org/docs/19/runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["track_activities","shared_preload_libraries","log_line_prefix","track_activity_query_size"],"summary":"compute_query_id — Enables in-core computation of query identifiers. Observed in PG14–19 Beta 4; its last measured boot default is auto in PG19 Beta 4, with superuser context. This is a beta-snapshot fact and can change before PostgreSQL 19 GA."},"enumvals":[],"first_version":"14","group":"Statistics","group_slug":"statistics","imported_at":"2026-09-27T17:57:30.973133+08:00","intro_commit":{"authored_at":"2021-04-07T13:06:47-04:00","discussion":["https://postgr.es/m/20210407125726.tkvjdbw76hxnpwfi@nol"],"hash":"5fd9dfa5f50e4906c35133a414ebec5b6d518493","subject":"Move pg_stat_statements query jumbling to core.","url":"https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=5fd9dfa5f50e4906c35133a414ebec5b6d518493"},"key":"compute_query_id","last_version":"20","max_val":"","min_val":"","name":"compute_query_id","position":67,"present_in":["14","15","16","17","18","19","20"],"short_desc":"Enables in-core computation of a query identifier.","short_desc_zh":"","source_rev":"english-manuals:94f2ae390fcb2930b192e8a924570b2c7f8c5244728696a710645bfe14b18933","unit":"","vartype":"enum"}},"Definition":{"Collection":"guc","Key":"compute_query_id","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"compute_query_id","SourceRevision":"english-manuals:94f2ae390fcb2930b192e8a924570b2c7f8c5244728696a710645bfe14b18933","Facts":{"boot_val":"auto","category":"Statistics / Monitoring","context":"superuser","description":"Enables in-core computation of a query identifier. Query identifiers can be displayed in the pg_stat_activity view, using EXPLAIN, or emitted in the log if configured via the log_line_prefix parameter. The pg_stat_statements extension also requires a query identifier to be computed. Note that an external module can alternatively be used if the in-core query identifier computation method is not acceptable. In this case, in-core computation must be always disabled. Valid values are off (always disabled), on (always enabled), auto, which lets modules such as pg_stat_statements automatically enable it, and regress which has the same effect as auto, except that the query identifier is not shown in the EXPLAIN output in order to facilitate automated regression testing. The default is auto. Note To ensure that only one query identifier is calculated and displayed, extensions that calculate query identifiers should throw an error if a query identifier has already been computed.","doc":{"anchor":"GUC-COMPUTE-QUERY-ID","file":"runtime-config-statistics.html","lang":"en","sha256":"90db46d4b011d54f415934fcc658b0841d07af25ae591483c2139ba0e114ed21","slug":"18"},"documented":true,"enumvals":["auto","regress","on","off"],"extra_desc":null,"lang":"en","max_val":null,"metadata_version":"18","min_val":null,"name":"compute_query_id","short_desc":"Enables in-core computation of query identifiers.","source":"pg-settings-source-snapshot","unit":null,"vartype":"enum"},"ManualEvidence":{"doc":{"anchor":"GUC-COMPUTE-QUERY-ID","file":"runtime-config-statistics.html","lang":"en","sha256":"90db46d4b011d54f415934fcc658b0841d07af25ae591483c2139ba0e114ed21","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"compute_query_id","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"compute_query_id","Summary":"","BodyHTML":"\u003cp\u003e启用内置的查询标识符计算功能。查询标识符可以显示在\u003ca href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW\" rel=\"nofollow\"\u003e\u003ccode\u003epg_stat_activity\u003c/code\u003e\u003c/a\u003e视图或\u003ccode\u003eEXPLAIN\u003c/code\u003e的输出中，也可以通过\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-LINE-PREFIX\" rel=\"nofollow\"\u003elog_line_prefix\u003c/a\u003e参数配置后写入日志。\u003ca href=\"/docs/18/pgstatstatements.html\" rel=\"nofollow\"\u003epg_stat_statements\u003c/a\u003e扩展也要求计算查询标识符。注意，如果内置的查询标识符计算方法不符合要求，可以改用外部模块。在这种情况下，必须始终禁用内置计算功能。有效值为\u003ccode\u003eoff\u003c/code\u003e（始终禁用）、\u003ccode\u003eon\u003c/code\u003e（始终启用）、\u003ccode\u003eauto\u003c/code\u003e（允许\u003ca href=\"/docs/18/pgstatstatements.html\" rel=\"nofollow\"\u003epg_stat_statements\u003c/a\u003e等模块自动启用此功能），以及\u003ccode\u003eregress\u003c/code\u003e。后者与\u003ccode\u003eauto\u003c/code\u003e效果相同，但不会在\u003ccode\u003eEXPLAIN\u003c/code\u003e输出中显示查询标识符，以便进行自动回归测试。默认值为\u003ccode\u003eauto\u003c/code\u003e。\u003c/p\u003e\u003cdiv\u003e\n注意\u003cp\u003e为确保只有一个查询标识符被计算和显示，计算查询标识符的扩展在查询标识符已被计算时应当抛出一个错误。\u003c/p\u003e\u003c/div\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"14d9aba89fbf3dad2d0b633b96cdf2983054ac17e4339d7b7c9e0d86c6c4cb82","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e启用内置的查询标识符计算功能。查询标识符可以显示在\u003ca href=\"/docs/18/monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW\" title=\"27.2.3. pg_stat_activity\"\u003e\u003ccode class=\"structname\"\u003epg_stat_activity\u003c/code\u003e\u003c/a\u003e视图或\u003ccode class=\"command\"\u003eEXPLAIN\u003c/code\u003e的输出中，也可以通过\u003ca href=\"/docs/18/runtime-config-logging.html#GUC-LOG-LINE-PREFIX\"\u003elog_line_prefix\u003c/a\u003e参数配置后写入日志。\u003ca href=\"/docs/18/pgstatstatements.html\" title=\"F.32. pg_stat_statements — 跟踪 SQL 计划和执行统计信息\"\u003epg_stat_statements\u003c/a\u003e扩展也要求计算查询标识符。注意，如果内置的查询标识符计算方法不符合要求，可以改用外部模块。在这种情况下，必须始终禁用内置计算功能。有效值为\u003ccode class=\"literal\"\u003eoff\u003c/code\u003e（始终禁用）、\u003ccode class=\"literal\"\u003eon\u003c/code\u003e（始终启用）、\u003ccode class=\"literal\"\u003eauto\u003c/code\u003e（允许\u003ca href=\"/docs/18/pgstatstatements.html\" title=\"F.32. pg_stat_statements — 跟踪 SQL 计划和执行统计信息\"\u003epg_stat_statements\u003c/a\u003e等模块自动启用此功能），以及\u003ccode class=\"literal\"\u003eregress\u003c/code\u003e。后者与\u003ccode class=\"literal\"\u003eauto\u003c/code\u003e效果相同，但不会在\u003ccode class=\"literal\"\u003eEXPLAIN\u003c/code\u003e输出中显示查询标识符，以便进行自动回归测试。默认值为\u003ccode class=\"literal\"\u003eauto\u003c/code\u003e。\u003c/p\u003e\u003cdiv class=\"note\"\u003e\n注意\u003cp\u003e为确保只有一个查询标识符被计算和显示，计算查询标识符的扩展在查询标识符已被计算时应当抛出一个错误。\u003c/p\u003e\u003c/div\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["14","15","16","17","18","19","20"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
