-
+
Server Configuration
+
+ stats_temp_directory (string)
+
+
stats_temp_directory> configuration parameter
+
+
+ Sets the directory to store temporary statistics data in. This can be a
+ path relative to the data directory or an absolute path. The default is
+ pg_stat_tmp. Pointing this at a RAM based filesystem
+ will decrease physical I/O requirements and can lead to increased
+ performance. This parameter can only be set at server start.
+
+
+
+
-
+
Monitoring Database Activity
These files are stored in the pg_stat_tmp subdirectory.
When the postmaster shuts down, a permanent copy of the statistics
data is stored in the global subdirectory. For increased
- performance, it is possible to mount or symlink a RAM based
- filesystem to the pg_stat_tmp directory.
+ performance, the parameter can
+ be pointed at a RAM based filesystem, decreasing physical I/O requirements.
*
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.178 2008/08/05 12:09:30 mha Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.179 2008/08/15 08:37:39 mha Exp $
* ----------
*/
#include "postgres.h"
*/
#define PGSTAT_STAT_PERMANENT_FILENAME "global/pgstat.stat"
#define PGSTAT_STAT_PERMANENT_TMPFILE "global/pgstat.tmp"
-#define PGSTAT_STAT_FILENAME "pg_stat_tmp/pgstat.stat"
-#define PGSTAT_STAT_TMPFILE "pg_stat_tmp/pgstat.tmp"
/* ----------
* Timer definitions.
int pgstat_track_functions = TRACK_FUNC_OFF;
int pgstat_track_activity_query_size = 1024;
+/* ----------
+ * Built from GUC parameter
+ * ----------
+ */
+char *pgstat_stat_filename = NULL;
+char *pgstat_stat_tmpname = NULL;
+
/*
* BgWriter global statistics counters (unused in other processes).
* Stored directly in a stats message structure so it can be sent
void
pgstat_reset_all(void)
{
- unlink(PGSTAT_STAT_FILENAME);
+ unlink(pgstat_stat_filename);
unlink(PGSTAT_STAT_PERMANENT_FILENAME);
}
PgStat_StatFuncEntry *funcentry;
FILE *fpout;
int32 format_id;
- const char *tmpfile = permanent?PGSTAT_STAT_PERMANENT_TMPFILE:PGSTAT_STAT_TMPFILE;
- const char *statfile = permanent?PGSTAT_STAT_PERMANENT_FILENAME:PGSTAT_STAT_FILENAME;
+ const char *tmpfile = permanent?PGSTAT_STAT_PERMANENT_TMPFILE:pgstat_stat_tmpname;
+ const char *statfile = permanent?PGSTAT_STAT_PERMANENT_FILENAME:pgstat_stat_filename;
/*
* Open the statistics temp file to write out the current values.
}
if (permanent)
- unlink(PGSTAT_STAT_FILENAME);
+ unlink(pgstat_stat_filename);
}
FILE *fpin;
int32 format_id;
bool found;
- const char *statfile = permanent?PGSTAT_STAT_PERMANENT_FILENAME:PGSTAT_STAT_FILENAME;
+ const char *statfile = permanent?PGSTAT_STAT_PERMANENT_FILENAME:pgstat_stat_filename;
/*
* The tables will live in pgStatLocalContext.
* Written by Peter Eisentraut
.
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.465 2008/07/23 17:29:53 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.466 2008/08/15 08:37:40 mha Exp $
*
*--------------------------------------------------------------------
*/
static const char *show_tcp_keepalives_count(void);
static bool assign_autovacuum_max_workers(int newval, bool doit, GucSource source);
static bool assign_maxconnections(int newval, bool doit, GucSource source);
+static const char *assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source);
static char *config_enum_get_options(struct config_enum *record,
const char *prefix, const char *suffix);
char *IdentFileName;
char *external_pid_file;
+char *pgstat_temp_directory;
+
int tcp_keepalives_idle;
int tcp_keepalives_interval;
int tcp_keepalives_count;
NULL, assign_canonical_path, NULL
},
+ {
+ {"stats_temp_directory", PGC_POSTMASTER, STATS_COLLECTOR,
+ gettext_noop("Writes temporary statistics files to the specified directory."),
+ NULL,
+ GUC_SUPERUSER_ONLY
+ },
+ &pgstat_temp_directory,
+ "pg_stat_tmp", assign_pgstat_temp_directory, NULL
+ },
+
{
{"default_text_search_config", PGC_USERSET, CLIENT_CONN_LOCALE,
gettext_noop("Sets default text search configuration."),
return true;
}
+static const char *
+assign_pgstat_temp_directory(const char *newval, bool doit, GucSource source)
+{
+ if (doit)
+ {
+ if (pgstat_stat_tmpname)
+ free(pgstat_stat_tmpname);
+ if (pgstat_stat_filename)
+ free(pgstat_stat_filename);
+
+ pgstat_stat_tmpname = guc_malloc(FATAL, strlen(newval) + 12); /* /pgstat.tmp */
+ pgstat_stat_filename = guc_malloc(FATAL, strlen(newval) + 13); /* /pgstat.stat */
+
+ sprintf(pgstat_stat_tmpname, "%s/pgstat.tmp", newval);
+ sprintf(pgstat_stat_filename, "%s/pgstat.stat", newval);
+ }
+
+ return newval;
+}
+
#include "guc-file.c"
#track_functions = none # none, pl, all
#track_activity_query_size = 1024
#update_process_title = on
+#stats_temp_directory = 'pg_stat_tmp'
# - Statistics Monitoring -
*
* Copyright (c) 2001-2008, PostgreSQL Global Development Group
*
- * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.77 2008/06/30 10:58:47 heikki Exp $
+ * $PostgreSQL: pgsql/src/include/pgstat.h,v 1.78 2008/08/15 08:37:40 mha Exp $
* ----------
*/
#ifndef PGSTAT_H
extern bool pgstat_track_counts;
extern int pgstat_track_functions;
extern int pgstat_track_activity_query_size;
+extern char *pgstat_stat_tmpname;
+extern char *pgstat_stat_filename;
/*
* BgWriter statistics counters are updated directly by bgwriter and bufmgr