summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorPeter Eisentraut2023-07-03 05:09:22 +0000
committerPeter Eisentraut2023-07-03 05:18:57 +0000
commit7a7f60aef8bf86b1a94908e20edd107fa9da4f3d (patch)
treec721557e084b0f60ddcf310246ad71409e527ec8 /src/include
parent3ee2f25d21faa123dc5bb2886a00a54bdddd1c3e (diff)
Add macro for maximum statistics target
The number of places where 10000 was hardcoded had grown a bit beyond the comfort level. Introduce a macro MAX_STATISTICS_TARGET instead. Reviewed-by: Tomas Vondra <tomas.vondra@enterprisedb.com> Discussion: https://www.postgresql.org/message-id/flat/d6069765-5971-04d3-c10d-e4f7b2e9c459%40eisentraut.org
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/pg_attribute.h2
-rw-r--r--src/include/commands/vacuum.h7
-rw-r--r--src/include/statistics/statistics.h4
3 files changed, 10 insertions, 3 deletions
diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h
index f8b4861b94a..f00df488ce7 100644
--- a/src/include/catalog/pg_attribute.h
+++ b/src/include/catalog/pg_attribute.h
@@ -165,7 +165,7 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
* that no value has been explicitly set for this column, so ANALYZE
* should use the default setting.
*
- * int16 is sufficient because the max value is currently 10000.
+ * int16 is sufficient for the current max value (MAX_STATISTICS_TARGET).
*/
int16 attstattarget BKI_DEFAULT(-1);
diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h
index cb5b11ab31f..bda7792770a 100644
--- a/src/include/commands/vacuum.h
+++ b/src/include/commands/vacuum.h
@@ -305,6 +305,13 @@ extern PGDLLIMPORT int vacuum_multixact_freeze_table_age;
extern PGDLLIMPORT int vacuum_failsafe_age;
extern PGDLLIMPORT int vacuum_multixact_failsafe_age;
+/*
+ * Maximum value for default_statistics_target and per-column statistics
+ * targets. This is fairly arbitrary, mainly to prevent users from creating
+ * unreasonably large statistics that the system cannot handle well.
+ */
+#define MAX_STATISTICS_TARGET 10000
+
/* Variables for cost-based parallel vacuum */
extern PGDLLIMPORT pg_atomic_uint32 *VacuumSharedCostBalance;
extern PGDLLIMPORT pg_atomic_uint32 *VacuumActiveNWorkers;
diff --git a/src/include/statistics/statistics.h b/src/include/statistics/statistics.h
index 17e3e7f881d..5e538fec32f 100644
--- a/src/include/statistics/statistics.h
+++ b/src/include/statistics/statistics.h
@@ -66,8 +66,8 @@ typedef struct MVDependencies
#define STATS_MCV_MAGIC 0xE1A651C2 /* marks serialized bytea */
#define STATS_MCV_TYPE_BASIC 1 /* basic MCV list type */
-/* max items in MCV list (should be equal to max default_statistics_target) */
-#define STATS_MCVLIST_MAX_ITEMS 10000
+/* max items in MCV list */
+#define STATS_MCVLIST_MAX_ITEMS MAX_STATISTICS_TARGET
/*
* Multivariate MCV (most-common value) lists