Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5b8eb2b

Browse files
committed
Make the temporary directory for pgstat files configurable by the GUC
variable stats_temp_directory, instead of requiring the admin tomount/symlink the pg_stat_tmp directory manually.For now the config variable is PGC_POSTMASTER. Room for further improvmentthat would allow it to be changed on-the-fly.
1 parentf24f233 commit5b8eb2b

File tree

6 files changed

+71
-14
lines changed

6 files changed

+71
-14
lines changed

‎doc/src/sgml/config.sgml

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.184 2008/07/18 17:33:17 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/config.sgml,v 1.185 2008/08/15 08:37:41 mha Exp $ -->
22

33
<chapter Id="runtime-config">
44
<title>Server Configuration</title>
@@ -3394,6 +3394,22 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv;
33943394
</listitem>
33953395
</varlistentry>
33963396

3397+
<varlistentry id="guc-stats-temp-directory" xreflabel="stats_temp_directory">
3398+
<term><varname>stats_temp_directory</varname> (<type>string</type>)</term>
3399+
<indexterm>
3400+
<primary><varname>stats_temp_directory</> configuration parameter</primary>
3401+
</indexterm>
3402+
<listitem>
3403+
<para>
3404+
Sets the directory to store temporary statistics data in. This can be a
3405+
path relative to the data directory or an absolute path. The default is
3406+
<filename>pg_stat_tmp</filename>. Pointing this at a RAM based filesystem
3407+
will decrease physical I/O requirements and can lead to increased
3408+
performance. This parameter can only be set at server start.
3409+
</para>
3410+
</listitem>
3411+
</varlistentry>
3412+
33973413
</variablelist>
33983414
</sect2>
33993415

‎doc/src/sgml/monitoring.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.61 2008/08/05 12:09:30 mha Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.62 2008/08/15 08:37:41 mha Exp $ -->
22

33
<chapter id="monitoring">
44
<title>Monitoring Database Activity</title>
@@ -171,8 +171,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
171171
These files are stored in the <filename>pg_stat_tmp</filename> subdirectory.
172172
When the postmaster shuts down, a permanent copy of the statistics
173173
data is stored in the <filename>global</filename> subdirectory. For increased
174-
performance,it is possible to mount or symlink a RAM based
175-
filesystem to the <filename>pg_stat_tmp</filename> directory.
174+
performance,the parameter <xref linkend="guc-stats-temp-directory"> can
175+
be pointed at a RAM basedfilesystem, decreasing physical I/O requirements.
176176
</para>
177177

178178
</sect2>

‎src/backend/postmaster/pgstat.c

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*
1414
*Copyright (c) 2001-2008, PostgreSQL Global Development Group
1515
*
16-
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.178 2008/08/05 12:09:30 mha Exp $
16+
*$PostgreSQL: pgsql/src/backend/postmaster/pgstat.c,v 1.179 2008/08/15 08:37:39 mha Exp $
1717
* ----------
1818
*/
1919
#include"postgres.h"
@@ -70,8 +70,6 @@
7070
*/
7171
#definePGSTAT_STAT_PERMANENT_FILENAME"global/pgstat.stat"
7272
#definePGSTAT_STAT_PERMANENT_TMPFILE"global/pgstat.tmp"
73-
#definePGSTAT_STAT_FILENAME"pg_stat_tmp/pgstat.stat"
74-
#definePGSTAT_STAT_TMPFILE"pg_stat_tmp/pgstat.tmp"
7573

7674
/* ----------
7775
* Timer definitions.
@@ -106,6 +104,13 @@ boolpgstat_track_counts = false;
106104
intpgstat_track_functions=TRACK_FUNC_OFF;
107105
intpgstat_track_activity_query_size=1024;
108106

107+
/* ----------
108+
* Built from GUC parameter
109+
* ----------
110+
*/
111+
char*pgstat_stat_filename=NULL;
112+
char*pgstat_stat_tmpname=NULL;
113+
109114
/*
110115
* BgWriter global statistics counters (unused in other processes).
111116
* Stored directly in a stats message structure so it can be sent
@@ -511,7 +516,7 @@ pgstat_init(void)
511516
void
512517
pgstat_reset_all(void)
513518
{
514-
unlink(PGSTAT_STAT_FILENAME);
519+
unlink(pgstat_stat_filename);
515520
unlink(PGSTAT_STAT_PERMANENT_FILENAME);
516521
}
517522

@@ -2911,8 +2916,8 @@ pgstat_write_statsfile(bool permanent)
29112916
PgStat_StatFuncEntry*funcentry;
29122917
FILE*fpout;
29132918
int32format_id;
2914-
constchar*tmpfile=permanent?PGSTAT_STAT_PERMANENT_TMPFILE:PGSTAT_STAT_TMPFILE;
2915-
constchar*statfile=permanent?PGSTAT_STAT_PERMANENT_FILENAME:PGSTAT_STAT_FILENAME;
2919+
constchar*tmpfile=permanent?PGSTAT_STAT_PERMANENT_TMPFILE:pgstat_stat_tmpname;
2920+
constchar*statfile=permanent?PGSTAT_STAT_PERMANENT_FILENAME:pgstat_stat_filename;
29162921

29172922
/*
29182923
* Open the statistics temp file to write out the current values.
@@ -3012,7 +3017,7 @@ pgstat_write_statsfile(bool permanent)
30123017
}
30133018

30143019
if (permanent)
3015-
unlink(PGSTAT_STAT_FILENAME);
3020+
unlink(pgstat_stat_filename);
30163021
}
30173022

30183023

@@ -3039,7 +3044,7 @@ pgstat_read_statsfile(Oid onlydb, bool permanent)
30393044
FILE*fpin;
30403045
int32format_id;
30413046
boolfound;
3042-
constchar*statfile=permanent?PGSTAT_STAT_PERMANENT_FILENAME:PGSTAT_STAT_FILENAME;
3047+
constchar*statfile=permanent?PGSTAT_STAT_PERMANENT_FILENAME:pgstat_stat_filename;
30433048

30443049
/*
30453050
* The tables will live in pgStatLocalContext.

‎src/backend/utils/misc/guc.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Written by Peter Eisentraut <peter_e@gmx.net>.
1111
*
1212
* IDENTIFICATION
13-
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.465 2008/07/23 17:29:53 tgl Exp $
13+
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.466 2008/08/15 08:37:40 mha Exp $
1414
*
1515
*--------------------------------------------------------------------
1616
*/
@@ -164,6 +164,7 @@ static const char *show_tcp_keepalives_interval(void);
164164
staticconstchar*show_tcp_keepalives_count(void);
165165
staticboolassign_autovacuum_max_workers(intnewval,booldoit,GucSourcesource);
166166
staticboolassign_maxconnections(intnewval,booldoit,GucSourcesource);
167+
staticconstchar*assign_pgstat_temp_directory(constchar*newval,booldoit,GucSourcesource);
167168

168169
staticchar*config_enum_get_options(structconfig_enum*record,
169170
constchar*prefix,constchar*suffix);
@@ -343,6 +344,8 @@ char *HbaFileName;
343344
char*IdentFileName;
344345
char*external_pid_file;
345346

347+
char*pgstat_temp_directory;
348+
346349
inttcp_keepalives_idle;
347350
inttcp_keepalives_interval;
348351
inttcp_keepalives_count;
@@ -2466,6 +2469,16 @@ static struct config_string ConfigureNamesString[] =
24662469
NULL,assign_canonical_path,NULL
24672470
},
24682471

2472+
{
2473+
{"stats_temp_directory",PGC_POSTMASTER,STATS_COLLECTOR,
2474+
gettext_noop("Writes temporary statistics files to the specified directory."),
2475+
NULL,
2476+
GUC_SUPERUSER_ONLY
2477+
},
2478+
&pgstat_temp_directory,
2479+
"pg_stat_tmp",assign_pgstat_temp_directory,NULL
2480+
},
2481+
24692482
{
24702483
{"default_text_search_config",PGC_USERSET,CLIENT_CONN_LOCALE,
24712484
gettext_noop("Sets default text search configuration."),
@@ -7370,4 +7383,24 @@ assign_autovacuum_max_workers(int newval, bool doit, GucSource source)
73707383
return true;
73717384
}
73727385

7386+
staticconstchar*
7387+
assign_pgstat_temp_directory(constchar*newval,booldoit,GucSourcesource)
7388+
{
7389+
if (doit)
7390+
{
7391+
if (pgstat_stat_tmpname)
7392+
free(pgstat_stat_tmpname);
7393+
if (pgstat_stat_filename)
7394+
free(pgstat_stat_filename);
7395+
7396+
pgstat_stat_tmpname=guc_malloc(FATAL,strlen(newval)+12);/* /pgstat.tmp */
7397+
pgstat_stat_filename=guc_malloc(FATAL,strlen(newval)+13);/* /pgstat.stat */
7398+
7399+
sprintf(pgstat_stat_tmpname,"%s/pgstat.tmp",newval);
7400+
sprintf(pgstat_stat_filename,"%s/pgstat.stat",newval);
7401+
}
7402+
7403+
returnnewval;
7404+
}
7405+
73737406
#include"guc-file.c"

‎src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,7 @@
366366
#track_functions = none# none, pl, all
367367
#track_activity_query_size = 1024
368368
#update_process_title = on
369+
#stats_temp_directory = 'pg_stat_tmp'
369370

370371

371372
# - Statistics Monitoring -

‎src/include/pgstat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*Copyright (c) 2001-2008, PostgreSQL Global Development Group
77
*
8-
*$PostgreSQL: pgsql/src/include/pgstat.h,v 1.77 2008/06/30 10:58:47 heikki Exp $
8+
*$PostgreSQL: pgsql/src/include/pgstat.h,v 1.78 2008/08/15 08:37:40 mha Exp $
99
* ----------
1010
*/
1111
#ifndefPGSTAT_H
@@ -576,6 +576,8 @@ extern bool pgstat_track_activities;
576576
externboolpgstat_track_counts;
577577
externintpgstat_track_functions;
578578
externintpgstat_track_activity_query_size;
579+
externchar*pgstat_stat_tmpname;
580+
externchar*pgstat_stat_filename;
579581

580582
/*
581583
* BgWriter statistics counters are updated directly by bgwriter and bufmgr

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp