aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/analyze.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2002-07-31 17:19:54 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2002-07-31 17:19:54 +0000
commitce7565ab91100747d250ef67d72af5c1b01150d4 (patch)
tree968d1af6054a60d13e292d786c2f695da02b2a9d /src/backend/commands/analyze.c
parent8be3cfbbd5e9afaa77a86251566d3ca04217fcb2 (diff)
downloadpostgresql-ce7565ab91100747d250ef67d72af5c1b01150d4.tar.gz
postgresql-ce7565ab91100747d250ef67d72af5c1b01150d4.zip
Instead of having a configure-time DEFAULT_ATTSTATTARGET, store -1 in
attstattarget to indicate 'use the default'. The default is now a GUC variable default_statistics_target, and so may be changed on the fly. Along the way we gain the ability to have pg_dump dump the per-column statistics target when it's not the default. Patch by Neil Conway, with some kibitzing from Tom Lane.
Diffstat (limited to 'src/backend/commands/analyze.c')
-rw-r--r--src/backend/commands/analyze.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index 6caa968b5d2..55069aa6feb 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.38 2002/06/20 20:29:26 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.39 2002/07/31 17:19:51 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -107,6 +107,11 @@ typedef struct
#define swapInt(a,b) do {int _tmp; _tmp=a; a=b; b=_tmp;} while(0)
#define swapDatum(a,b) do {Datum _tmp; _tmp=a; a=b; b=_tmp;} while(0)
+
+/* Default statistics target (GUC parameter) */
+int default_statistics_target = 10;
+
+
static int elevel = -1;
static MemoryContext anl_context = NULL;
@@ -384,7 +389,7 @@ examine_attribute(Relation onerel, int attnum)
VacAttrStats *stats;
/* Don't analyze column if user has specified not to */
- if (attr->attstattarget <= 0)
+ if (attr->attstattarget == 0)
return NULL;
/* If column has no "=" operator, we can't do much of anything */
@@ -425,6 +430,10 @@ examine_attribute(Relation onerel, int attnum)
stats->eqopr = eqopr;
stats->eqfunc = eqfunc;
+ /* If the attstattarget column is negative, use the default value */
+ if (stats->attr->attstattarget < 0)
+ stats->attr->attstattarget = default_statistics_target;
+
/* Is there a "<" operator with suitable semantics? */
func_operator = compatible_oper(makeList1(makeString("<")),
attr->atttypid,
@@ -466,14 +475,14 @@ examine_attribute(Relation onerel, int attnum)
* know it at this point.
*--------------------
*/
- stats->minrows = 300 * attr->attstattarget;
+ stats->minrows = 300 * stats->attr->attstattarget;
}
else
{
/* Can't do much but the minimal stuff */
stats->algcode = ALG_MINIMAL;
/* Might as well use the same minrows as above */
- stats->minrows = 300 * attr->attstattarget;
+ stats->minrows = 300 * stats->attr->attstattarget;
}
return stats;