mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
Rework temp_tablespaces patch so that temp tablespaces are assigned separately
for each temp file, rather than once per sort or hashjoin; this allows spreading the data of a large sort or join across multiple tablespaces. (I remain dubious that this will make any difference in practice, but certain people insisted.) Arrange to cache the results of parsing the GUC variable instead of recomputing from scratch on every demand, and push usage of the cache down to the bottommost fd.c level.
This commit is contained in:
@@ -70,14 +70,13 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.24 2007/06/03 17:08:23 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/logtape.c,v 1.25 2007/06/07 19:19:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
|
||||
#include "commands/tablespace.h"
|
||||
#include "storage/buffile.h"
|
||||
#include "utils/logtape.h"
|
||||
|
||||
@@ -529,7 +528,7 @@ LogicalTapeSetCreate(int ntapes)
|
||||
Assert(ntapes > 0);
|
||||
lts = (LogicalTapeSet *) palloc(sizeof(LogicalTapeSet) +
|
||||
(ntapes - 1) *sizeof(LogicalTape));
|
||||
lts->pfile = BufFileCreateTemp(false, GetTempTablespace());
|
||||
lts->pfile = BufFileCreateTemp(false);
|
||||
lts->nFileBlocks = 0L;
|
||||
lts->forgetFreeSpace = false;
|
||||
lts->blocksSorted = true; /* a zero-length array is sorted ... */
|
||||
|
@@ -91,7 +91,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.76 2007/05/04 21:29:53 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.77 2007/06/07 19:19:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -104,6 +104,7 @@
|
||||
#include "access/nbtree.h"
|
||||
#include "catalog/pg_amop.h"
|
||||
#include "catalog/pg_operator.h"
|
||||
#include "commands/tablespace.h"
|
||||
#include "miscadmin.h"
|
||||
#include "utils/datum.h"
|
||||
#include "utils/logtape.h"
|
||||
@@ -1479,6 +1480,12 @@ inittapes(Tuplesortstate *state)
|
||||
if (tapeSpace + GetMemoryChunkSpace(state->memtuples) < state->allowedMem)
|
||||
USEMEM(state, tapeSpace);
|
||||
|
||||
/*
|
||||
* Make sure that the temp file(s) underlying the tape set are created in
|
||||
* suitable temp tablespaces.
|
||||
*/
|
||||
PrepareTempTablespaces();
|
||||
|
||||
/*
|
||||
* Create the tape set and allocate the per-tape data arrays.
|
||||
*/
|
||||
|
@@ -38,7 +38,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.32 2007/06/03 17:08:26 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.33 2007/06/07 19:19:57 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -424,15 +424,11 @@ tuplestore_puttuple_common(Tuplestorestate *state, void *tuple)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Nope; time to switch to tape-based operation.
|
||||
*
|
||||
* If the temp table is slated to outlive the current transaction,
|
||||
* force it into my database's default tablespace, so that it will
|
||||
* not pose a threat to possible tablespace drop attempts.
|
||||
* Nope; time to switch to tape-based operation. Make sure that
|
||||
* the temp file(s) are created in suitable temp tablespaces.
|
||||
*/
|
||||
state->myfile = BufFileCreateTemp(state->interXact,
|
||||
state->interXact ? InvalidOid :
|
||||
GetTempTablespace());
|
||||
PrepareTempTablespaces();
|
||||
state->myfile = BufFileCreateTemp(state->interXact);
|
||||
state->status = TSS_WRITEFILE;
|
||||
dumptuples(state);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user