mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Create a GUC parameter temp_tablespaces that allows selection of the
tablespace(s) in which to store temp tables and temporary files. This is a list to allow spreading the load across multiple tablespaces (a random list element is chosen each time a temp object is to be created). Temp files are not stored in per-database pgsql_tmp/ directories anymore, but per-tablespace directories. Jaime Casanova and Albert Cervera, with review by Bernd Helmle and Tom Lane.
This commit is contained in:
@ -26,7 +26,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.293 2007/04/27 22:05:47 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/execMain.c,v 1.294 2007/06/03 17:07:00 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -2430,7 +2430,7 @@ OpenIntoRel(QueryDesc *queryDesc)
|
||||
get_namespace_name(namespaceId));
|
||||
|
||||
/*
|
||||
* Select tablespace to use. If not specified, use default_tablespace
|
||||
* Select tablespace to use. If not specified, use default tablespace
|
||||
* (which may in turn default to database's default).
|
||||
*/
|
||||
if (into->tableSpaceName)
|
||||
@ -2444,7 +2444,7 @@ OpenIntoRel(QueryDesc *queryDesc)
|
||||
}
|
||||
else
|
||||
{
|
||||
tablespaceId = GetDefaultTablespace();
|
||||
tablespaceId = GetDefaultTablespace(into->rel->istemp);
|
||||
/* note InvalidOid is OK in this case */
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.112 2007/06/01 17:38:44 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHash.c,v 1.113 2007/06/03 17:07:14 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -24,6 +24,7 @@
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "commands/tablespace.h"
|
||||
#include "executor/execdebug.h"
|
||||
#include "executor/hashjoin.h"
|
||||
#include "executor/instrument.h"
|
||||
@ -266,6 +267,7 @@ ExecHashTableCreate(Hash *node, List *hashOperators)
|
||||
hashtable->totalTuples = 0;
|
||||
hashtable->innerBatchFile = NULL;
|
||||
hashtable->outerBatchFile = NULL;
|
||||
hashtable->hashTblSpc = InvalidOid;
|
||||
hashtable->spaceUsed = 0;
|
||||
hashtable->spaceAllowed = work_mem * 1024L;
|
||||
|
||||
@ -325,6 +327,8 @@ ExecHashTableCreate(Hash *node, List *hashOperators)
|
||||
hashtable->outerBatchFile = (BufFile **)
|
||||
palloc0(nbatch * sizeof(BufFile *));
|
||||
/* The files will not be opened until needed... */
|
||||
/* ... but we want to choose the tablespace only once */
|
||||
hashtable->hashTblSpc = GetTempTablespace();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -506,6 +510,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
|
||||
palloc0(nbatch * sizeof(BufFile *));
|
||||
hashtable->outerBatchFile = (BufFile **)
|
||||
palloc0(nbatch * sizeof(BufFile *));
|
||||
/* time to choose the tablespace, too */
|
||||
hashtable->hashTblSpc = GetTempTablespace();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -558,7 +564,8 @@ ExecHashIncreaseNumBatches(HashJoinTable hashtable)
|
||||
{
|
||||
/* dump it out */
|
||||
Assert(batchno > curbatch);
|
||||
ExecHashJoinSaveTuple(HJTUPLE_MINTUPLE(tuple),
|
||||
ExecHashJoinSaveTuple(hashtable,
|
||||
HJTUPLE_MINTUPLE(tuple),
|
||||
tuple->hashvalue,
|
||||
&hashtable->innerBatchFile[batchno]);
|
||||
/* and remove from hash table */
|
||||
@ -650,7 +657,8 @@ ExecHashTableInsert(HashJoinTable hashtable,
|
||||
* put the tuple into a temp file for later batches
|
||||
*/
|
||||
Assert(batchno > hashtable->curbatch);
|
||||
ExecHashJoinSaveTuple(tuple,
|
||||
ExecHashJoinSaveTuple(hashtable,
|
||||
tuple,
|
||||
hashvalue,
|
||||
&hashtable->innerBatchFile[batchno]);
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.89 2007/02/02 00:07:03 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/executor/nodeHashjoin.c,v 1.90 2007/06/03 17:07:26 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -223,7 +223,8 @@ ExecHashJoin(HashJoinState *node)
|
||||
* in the corresponding outer-batch file.
|
||||
*/
|
||||
Assert(batchno > hashtable->curbatch);
|
||||
ExecHashJoinSaveTuple(ExecFetchSlotMinimalTuple(outerTupleSlot),
|
||||
ExecHashJoinSaveTuple(hashtable,
|
||||
ExecFetchSlotMinimalTuple(outerTupleSlot),
|
||||
hashvalue,
|
||||
&hashtable->outerBatchFile[batchno]);
|
||||
node->hj_NeedNewOuter = true;
|
||||
@ -754,7 +755,8 @@ start_over:
|
||||
* will get messed up.
|
||||
*/
|
||||
void
|
||||
ExecHashJoinSaveTuple(MinimalTuple tuple, uint32 hashvalue,
|
||||
ExecHashJoinSaveTuple(HashJoinTable hashtable,
|
||||
MinimalTuple tuple, uint32 hashvalue,
|
||||
BufFile **fileptr)
|
||||
{
|
||||
BufFile *file = *fileptr;
|
||||
@ -763,7 +765,7 @@ ExecHashJoinSaveTuple(MinimalTuple tuple, uint32 hashvalue,
|
||||
if (file == NULL)
|
||||
{
|
||||
/* First write to this batch file, so open it. */
|
||||
file = BufFileCreateTemp(false);
|
||||
file = BufFileCreateTemp(false, hashtable->hashTblSpc);
|
||||
*fileptr = file;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user