{"Entry":{"collection":"guc","key":"default_statistics_target","name":"default_statistics_target","aliases":[],"metadata":{"baseline":true,"boot_human":"Not specified","boot_val":null,"category":"Query Tuning / Other Planner Options","category_zh":"","changed_in":[],"changes":[{"documentation_changed":true,"fields":{},"from":"7.4","status":"changed","to":"8.0"},{"documentation_changed":true,"fields":{},"from":"8.2","status":"changed","to":"8.3"},{"documentation_changed":true,"fields":{},"from":"8.3","status":"changed","to":"8.4"},{"documentation_changed":true,"fields":{},"from":"8.4","status":"changed","to":"9.0"}],"content_hash":"ebf785876d8a79e88c0c9627b9144f98978ac0a5a5d4074b4848c8c63146e009","context":"","default_changed_in":[],"default_history":[{"from":"9.0","to":"19","value":"100"}],"editorial":{"advice":{"olap":"A higher baseline can help complex filters and joins, but use extended statistics for correlated predicates and budget the extra ANALYZE time after bulk loads.","oltp":"Keep the global target moderate and raise it for skewed columns that actually produce row-estimate errors. Re-run ANALYZE and compare estimated versus actual rows before and after.","small":"A modest global increase is usually inexpensive, but per-column tuning remains more precise. Do not collect deep histograms for columns never used in predicates, grouping, or ordering."},"mechanism":["The target limits the number of entries in most-common-value lists and histogram bins stored for a column. The planner uses those statistics to estimate row counts, which feed access-path, join-order, and join-method decisions.","ANALYZE samples large tables rather than reading every row. Its sample size is driven by the largest statistics target among the columns being analyzed, so increasing the target raises analysis time and space roughly in proportion.","ALTER TABLE ... ALTER COLUMN ... SET STATISTICS overrides the global default for a column. Correlation between columns is a separate problem that normally requires CREATE STATISTICS rather than simply increasing this setting."],"pitfalls":["Changing the setting does not refresh existing statistics; ANALYZE must run afterward.","Higher single-column targets do not model cross-column correlation by themselves.","A high global target increases ANALYZE work even for unimportant columns.","Partitioned parents can require manual ANALYZE because child changes do not trigger it.","Approximate sampling can still produce estimation error and plan variation."],"references":[{"title":"PostgreSQL 19 Beta 4: default_statistics_target","url":"https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-DEFAULT-STATISTICS-TARGET"},{"title":"PostgreSQL 18: Statistics Used by the Planner","url":"https://www.postgresql.org/docs/18/planner-stats.html"},{"title":"PostgreSQL 18: ANALYZE","url":"https://www.postgresql.org/docs/18/sql-analyze.html"},{"title":"PostgreSQL 19 release notes","url":"https://www.postgresql.org/docs/19/release-19.html"}],"related":["autovacuum_analyze_scale_factor","autovacuum_analyze_threshold","enable_partitionwise_join","plan_cache_mode","random_page_cost","effective_cache_size"],"summary":"Sets the default detail level for column statistics collected by ANALYZE when a column has no explicit target. More detail can improve cardinality estimates at the cost of collection time and catalog space."},"enumvals":[],"first_version":"7.4","group":"Query Tuning","group_slug":"query","imported_at":"2026-09-27T17:57:31.085951+08:00","intro_commit":{},"key":"default_statistics_target","last_version":"20","max_val":"","min_val":"","name":"default_statistics_target","position":98,"present_in":["7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"short_desc":"Sets the default statistics target for table columns without a column-specific target set via ALTER TABLE SET STATISTICS.","short_desc_zh":"","source_rev":"english-manuals:974ece2c6e895d0c4902a0a40e1bcbef878ede28a018f03adb74d9b9fc455a86","unit":"","vartype":"integer"}},"Definition":{"Collection":"guc","Key":"default_statistics_target","SourceDatabase":"center","Version":"18","SourceTable":"guc","SourceKey":"default_statistics_target","SourceRevision":"english-manuals:974ece2c6e895d0c4902a0a40e1bcbef878ede28a018f03adb74d9b9fc455a86","Facts":{"boot_val":"100","category":"Query Tuning / Other Planner Options","context":"user","description":"Sets the default statistics target for table columns without a column-specific target set via ALTER TABLE SET STATISTICS. Larger values increase the time needed to do ANALYZE, but might improve the quality of the planner's estimates. The default is 100. For more information on the use of statistics by the PostgreSQL query planner, refer to Section 14.2.","doc":{"anchor":"GUC-DEFAULT-STATISTICS-TARGET","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"},"documented":true,"enumvals":null,"extra_desc":"This applies to table columns that have not had a column-specific target set via ALTER TABLE SET STATISTICS.","lang":"en","max_val":"10000","metadata_version":"18","min_val":"1","name":"default_statistics_target","short_desc":"Sets the default statistics target.","source":"pg-settings-source-snapshot","unit":null,"vartype":"integer"},"ManualEvidence":{"doc":{"anchor":"GUC-DEFAULT-STATISTICS-TARGET","file":"runtime-config-query.html","lang":"en","sha256":"33456ca7ef52bf28e93e34b932a411db7a1b95800179add2cf867dc6ec9144bc","slug":"18"}},"MeasuredEvidence":{"metadata_version":"18"}},"Text":{"Collection":"guc","Key":"default_statistics_target","SourceDatabase":"pgweb","Version":"18","Locale":"zh-Hans","Title":"default_statistics_target","Summary":"","BodyHTML":"\u003cp\u003e为没有通过\u003ccode\u003eALTER TABLE SET STATISTICS\u003c/code\u003e设置列相关目标的表列设置默认统计目标。更大的值增加了需要做\u003ccode\u003eANALYZE\u003c/code\u003e的时间，但是可能会改善规划器的估计质量。默认值是 100。有关\u003cspan\u003ePostgreSQL\u003c/span\u003e查询规划器使用的统计信息的更多内容，请参考\u003ca href=\"/docs/18/planner-stats.html\" rel=\"nofollow\"\u003e第 14.2 节\u003c/a\u003e。\u003c/p\u003e","SourceRevision":"2026-09-11@29c86d9","ContentHash":"656b5e674d7babc3f130e837cff28c5520a0576fa40246e99afb6df5b3983a66","Payload":{"carried_from":"","carry_reason":"","doc_html":"\u003cp\u003e为没有通过\u003ccode class=\"command\"\u003eALTER TABLE SET STATISTICS\u003c/code\u003e设置列相关目标的表列设置默认统计目标。更大的值增加了需要做\u003ccode class=\"command\"\u003eANALYZE\u003c/code\u003e的时间，但是可能会改善规划器的估计质量。默认值是 100。有关\u003cspan class=\"productname\"\u003ePostgreSQL\u003c/span\u003e查询规划器使用的统计信息的更多内容，请参考\u003ca href=\"/docs/18/planner-stats.html\" title=\"14.2. 规划器使用的统计信息\"\u003e第 14.2 节\u003c/a\u003e。\u003c/p\u003e","doc_same_as":""}},"RequestedLocale":"zh-Hans","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":null,"Spellings":null,"SQLState":null,"Evidence":null}
