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

Commitba4d223

Browse files
committed
Tweak memory context sizing for saved SPI plans.
1 parentecaa2e0 commitba4d223

File tree

1 file changed

+27
-20
lines changed
  • src/backend/executor

1 file changed

+27
-20
lines changed

‎src/backend/executor/spi.c

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,21 @@
33
* spi.c
44
*Server Programming Interface
55
*
6-
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.55 2001/06/01 19:43:55 tgl Exp $
6+
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
7+
* Portions Copyright (c) 1994, Regents of the University of California
8+
*
9+
*
10+
* IDENTIFICATION
11+
* $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.56 2001/08/02 16:05:23 tgl Exp $
712
*
813
*-------------------------------------------------------------------------
914
*/
10-
#include"executor/spi_priv.h"
15+
#include"postgres.h"
16+
1117
#include"access/printtup.h"
1218
#include"commands/command.h"
19+
#include"executor/spi_priv.h"
20+
1321

1422
uint32SPI_processed=0;
1523
OidSPI_lastoid=InvalidOid;
@@ -786,10 +794,10 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc, DestReceiver *self)
786794
if (tuptable==NULL)
787795
{
788796
tuptabcxt=AllocSetContextCreate(CurrentMemoryContext,
789-
"SPI TupTable",
790-
ALLOCSET_DEFAULT_MINSIZE,
791-
ALLOCSET_DEFAULT_INITSIZE,
792-
ALLOCSET_DEFAULT_MAXSIZE);
797+
"SPI TupTable",
798+
ALLOCSET_DEFAULT_MINSIZE,
799+
ALLOCSET_DEFAULT_INITSIZE,
800+
ALLOCSET_DEFAULT_MAXSIZE);
793801
MemoryContextSwitchTo(tuptabcxt);
794802

795803
_SPI_current->tuptable=tuptable= (SPITupleTable*)
@@ -1253,29 +1261,28 @@ _SPI_copy_plan(_SPI_plan *plan, int location)
12531261
_SPI_plan*newplan;
12541262
MemoryContextoldcxt;
12551263
MemoryContextplancxt;
1256-
MemoryContextparentcxt=CurrentMemoryContext;
1264+
MemoryContextparentcxt;
12571265

1258-
/* Determine correct parent for theplans memory context */
1266+
/* Determine correct parent for theplan's memory context */
12591267
if (location==_SPI_CPLAN_PROCXT)
12601268
parentcxt=_SPI_current->procCxt;
1261-
/*
1262-
oldcxt = MemoryContextSwitchTo(_SPI_current->procCxt);
1263-
*/
12641269
elseif (location==_SPI_CPLAN_TOPCXT)
12651270
parentcxt=TopMemoryContext;
1266-
/*
1267-
oldcxt = MemoryContextSwitchTo(TopMemoryContext);
1268-
*/
1271+
else
1272+
parentcxt=CurrentMemoryContext;
12691273

1270-
/* Create a memory context for the plan */
1274+
/*
1275+
* Create a memory context for the plan. We don't expect the plan to
1276+
* be very large, so use smaller-than-default alloc parameters.
1277+
*/
12711278
plancxt=AllocSetContextCreate(parentcxt,
1272-
"SPI Plan",
1273-
ALLOCSET_DEFAULT_MINSIZE,
1274-
ALLOCSET_DEFAULT_INITSIZE,
1275-
ALLOCSET_DEFAULT_MAXSIZE);
1279+
"SPI Plan",
1280+
1024,
1281+
1024,
1282+
ALLOCSET_DEFAULT_MAXSIZE);
12761283
oldcxt=MemoryContextSwitchTo(plancxt);
12771284

1278-
/* Copy the SPI plan intoit's own context */
1285+
/* Copy the SPI plan intoits own context */
12791286
newplan= (_SPI_plan*)palloc(sizeof(_SPI_plan));
12801287
newplan->plancxt=plancxt;
12811288
newplan->qtlist= (List*)copyObject(plan->qtlist);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp