mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +03:00
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.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.81 2002/07/20 05:16:56 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.82 2002/07/31 17:19:51 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* some of the executor utility code such as "ExecTypeFromTL" should be
|
||||
@@ -375,7 +375,7 @@ TupleDescInitEntry(TupleDesc desc,
|
||||
else
|
||||
MemSet(NameStr(att->attname), 0, NAMEDATALEN);
|
||||
|
||||
att->attstattarget = 0;
|
||||
att->attstattarget = -1;
|
||||
att->attcacheoff = -1;
|
||||
att->atttypmod = typmod;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.27 2002/04/27 21:24:33 tgl Exp $
|
||||
# $Header: /cvsroot/pgsql/src/backend/catalog/Attic/genbki.sh,v 1.28 2002/07/31 17:19:51 tgl Exp $
|
||||
#
|
||||
# NOTES
|
||||
# non-essential whitespace is removed from the generated file.
|
||||
@@ -126,12 +126,11 @@ for dir in $INCLUDE_DIRS; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Get INDEX_MAX_KEYS and DEFAULT_ATTSTATTARGET from pg_config.h
|
||||
# Get INDEX_MAX_KEYS from pg_config.h
|
||||
# (who needs consistency?)
|
||||
for dir in $INCLUDE_DIRS; do
|
||||
if [ -f "$dir/pg_config.h" ]; then
|
||||
INDEXMAXKEYS=`grep '^#define[ ]*INDEX_MAX_KEYS' $dir/pg_config.h | $AWK '{ print $3 }'`
|
||||
DEFAULTATTSTATTARGET=`grep '^#define[ ]*DEFAULT_ATTSTATTARGET' $dir/pg_config.h | $AWK '{ print $3 }'`
|
||||
break
|
||||
fi
|
||||
done
|
||||
@@ -194,7 +193,6 @@ sed -e "s/;[ ]*$//g" \
|
||||
-e "s/PGUID/1/g" \
|
||||
-e "s/NAMEDATALEN/$NAMEDATALEN/g" \
|
||||
-e "s/PGNSP/$PG_CATALOG_NAMESPACE/g" \
|
||||
-e "s/DEFAULT_ATTSTATTARGET/$DEFAULTATTSTATTARGET/g" \
|
||||
-e "s/INDEX_MAX_KEYS\*2/$INDEXMAXKEYS2/g" \
|
||||
-e "s/INDEX_MAX_KEYS\*4/$INDEXMAXKEYS4/g" \
|
||||
-e "s/INDEX_MAX_KEYS/$INDEXMAXKEYS/g" \
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.213 2002/07/24 19:11:07 petere Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.214 2002/07/31 17:19:51 tgl Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@@ -441,7 +441,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
|
||||
/* Fill in the correct relation OID */
|
||||
(*dpp)->attrelid = new_rel_oid;
|
||||
/* Make sure these are OK, too */
|
||||
(*dpp)->attstattarget = DEFAULT_ATTSTATTARGET;
|
||||
(*dpp)->attstattarget = -1;
|
||||
(*dpp)->attcacheoff = -1;
|
||||
|
||||
tup = heap_addheader(Natts_pg_attribute,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.24 2002/07/20 05:16:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.25 2002/07/31 17:19:51 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1668,7 +1668,7 @@ AlterTableAddColumn(Oid myrelid,
|
||||
attribute->attrelid = myrelid;
|
||||
namestrcpy(&(attribute->attname), colDef->colname);
|
||||
attribute->atttypid = HeapTupleGetOid(typeTuple);
|
||||
attribute->attstattarget = DEFAULT_ATTSTATTARGET;
|
||||
attribute->attstattarget = -1;
|
||||
attribute->attlen = tform->typlen;
|
||||
attribute->attcacheoff = -1;
|
||||
attribute->atttypmod = colDef->typename->typmod;
|
||||
@@ -2184,12 +2184,18 @@ AlterTableAlterColumnFlags(Oid myrelid,
|
||||
newtarget = intVal(flagValue);
|
||||
|
||||
/*
|
||||
* Limit target to sane range (should we raise an error instead?)
|
||||
* Limit target to a sane range
|
||||
*/
|
||||
if (newtarget < 0)
|
||||
newtarget = 0;
|
||||
if (newtarget < -1)
|
||||
{
|
||||
elog(ERROR, "ALTER TABLE: statistics target %d is too low",
|
||||
newtarget);
|
||||
}
|
||||
else if (newtarget > 1000)
|
||||
{
|
||||
elog(WARNING, "ALTER TABLE: lowering statistics target to 1000");
|
||||
newtarget = 1000;
|
||||
}
|
||||
}
|
||||
else if (*flagType == 'M')
|
||||
{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.351 2002/07/30 16:55:44 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.352 2002/07/31 17:19:51 tgl Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -1134,14 +1134,14 @@ AlterTableStmt:
|
||||
n->name = $6;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> SET STATISTICS <Iconst> */
|
||||
| ALTER TABLE relation_expr ALTER opt_column ColId SET STATISTICS Iconst
|
||||
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> SET STATISTICS <IntegerOnly> */
|
||||
| ALTER TABLE relation_expr ALTER opt_column ColId SET STATISTICS IntegerOnly
|
||||
{
|
||||
AlterTableStmt *n = makeNode(AlterTableStmt);
|
||||
n->subtype = 'S';
|
||||
n->relation = $3;
|
||||
n->name = $6;
|
||||
n->def = (Node *) makeInteger($9);
|
||||
n->def = (Node *) $9;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER TABLE <relation> ALTER [COLUMN] <colname> SET STORAGE <storagemode> */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* command, configuration file, and command line options.
|
||||
* See src/backend/utils/misc/README for more information.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.76 2002/07/30 16:20:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.77 2002/07/31 17:19:52 tgl Exp $
|
||||
*
|
||||
* Copyright 2000 by PostgreSQL Global Development Group
|
||||
* Written by Peter Eisentraut <peter_e@gmx.net>.
|
||||
@@ -26,6 +26,7 @@
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/async.h"
|
||||
#include "commands/variable.h"
|
||||
#include "commands/vacuum.h"
|
||||
#include "executor/executor.h"
|
||||
#include "fmgr.h"
|
||||
#include "libpq/auth.h"
|
||||
@@ -491,6 +492,10 @@ static struct config_bool
|
||||
static struct config_int
|
||||
ConfigureNamesInt[] =
|
||||
{
|
||||
{
|
||||
{ "default_statistics_target", PGC_USERSET }, &default_statistics_target,
|
||||
10, 1, 1000, NULL, NULL
|
||||
},
|
||||
{
|
||||
{ "geqo_threshold", PGC_USERSET }, &geqo_rels,
|
||||
DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
#cpu_index_tuple_cost = 0.001
|
||||
#cpu_operator_cost = 0.0025
|
||||
|
||||
#default_statistics_target = 10 # range 1-1000
|
||||
|
||||
#
|
||||
# GEQO Optimizer Parameters
|
||||
|
||||
Reference in New Issue
Block a user