1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-30 11:03:19 +03:00

Split pgstat file in smaller pieces

We now write one file per database and one global file, instead of
having the whole thing in a single huge file.  This reduces the I/O that
must be done when partial data is required -- which is all the time,
because each process only needs information on its own database anyway.
Also, the autovacuum launcher does not need data about tables and
functions in each database; having the global stats for all DBs is
enough.

Catalog version bumped because we have a new subdir under PGDATA.

Author: Tomas Vondra.  Some rework by Álvaro
Testing by Jeff Janes
Other discussion by Heikki Linnakangas, Tom Lane.
This commit is contained in:
Alvaro Herrera
2013-02-18 17:56:08 -03:00
parent 9475db3a4e
commit 187492b6c2
5 changed files with 601 additions and 247 deletions

View File

@ -8705,14 +8705,23 @@ static void
assign_pgstat_temp_directory(const char *newval, void *extra)
{
/* check_canonical_path already canonicalized newval for us */
char *dname;
char *tname;
char *fname;
tname = guc_malloc(ERROR, strlen(newval) + 12); /* /pgstat.tmp */
sprintf(tname, "%s/pgstat.tmp", newval);
fname = guc_malloc(ERROR, strlen(newval) + 13); /* /pgstat.stat */
sprintf(fname, "%s/pgstat.stat", newval);
/* directory */
dname = guc_malloc(ERROR, strlen(newval) + 1); /* runtime dir */
sprintf(dname, "%s", newval);
/* global stats */
tname = guc_malloc(ERROR, strlen(newval) + 12); /* /global.tmp */
sprintf(tname, "%s/global.tmp", newval);
fname = guc_malloc(ERROR, strlen(newval) + 13); /* /global.stat */
sprintf(fname, "%s/global.stat", newval);
if (pgstat_stat_directory)
free(pgstat_stat_directory);
pgstat_stat_directory = dname;
if (pgstat_stat_tmpname)
free(pgstat_stat_tmpname);
pgstat_stat_tmpname = tname;