Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
91728fa2
Commit
91728fa2
authored
Mar 19, 2005
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add temp_buffers GUC variable to allow users to determine the size
of the local buffer arena for temporary table access.
parent
d65522ae
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
28 deletions
+89
-28
doc/src/sgml/runtime.sgml
doc/src/sgml/runtime.sgml
+28
-1
src/backend/storage/buffer/localbuf.c
src/backend/storage/buffer/localbuf.c
+27
-19
src/backend/utils/init/postinit.c
src/backend/utils/init/postinit.c
+1
-2
src/backend/utils/misc/guc.c
src/backend/utils/misc/guc.c
+26
-2
src/backend/utils/misc/postgresql.conf.sample
src/backend/utils/misc/postgresql.conf.sample
+1
-0
src/bin/psql/tab-complete.c
src/bin/psql/tab-complete.c
+2
-1
src/include/storage/bufmgr.h
src/include/storage/bufmgr.h
+1
-2
src/include/utils/guc.h
src/include/utils/guc.h
+3
-1
No files found.
doc/src/sgml/runtime.sgml
View file @
91728fa2
<!--
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.3
09 2005/03/14 06:49:48 neilc
Exp $
$PostgreSQL: pgsql/doc/src/sgml/runtime.sgml,v 1.3
10 2005/03/19 23:27:04 tgl
Exp $
-->
<chapter Id="runtime">
...
...
@@ -1038,6 +1038,33 @@ SET ENABLE_SEQSCAN TO OFF;
</listitem>
</varlistentry>
<varlistentry id="guc-temp-buffers" xreflabel="temp_buffers">
<term><varname>temp_buffers</varname> (<type>integer</type>)</term>
<indexterm>
<primary><varname>temp_buffers</> configuration parameter</primary>
</indexterm>
<listitem>
<para>
Sets the maximum number of temporary buffers used by each database
session. These are session-local buffers used only for access
to temporary tables. The default is 1000. The setting can
be changed within individual sessions, but only up until the
first use of temporary tables within a session; subsequent
attempts to change the value will have no effect on that session.
</para>
<para>
A session will allocate temporary buffers as needed up to the limit
given by <varname>temp_buffers</>. The cost of setting a large
value in sessions that do not actually need a lot of temporary
buffers is only a buffer descriptor, or about 64 bytes, per
increment in <varname>temp_buffers</>. However if a buffer is
actually used an additional 8192 bytes will be consumed for it
(or in general <symbol>BLCKSZ</symbol> bytes).
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-work-mem" xreflabel="work_mem">
<term><varname>work_mem</varname> (<type>integer</type>)</term>
<indexterm>
...
...
src/backend/storage/buffer/localbuf.c
View file @
91728fa2
...
...
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.6
5 2005/03/19 17:39:43
tgl Exp $
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.6
6 2005/03/19 23:27:05
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -18,6 +18,7 @@
#include "storage/buf_internals.h"
#include "storage/bufmgr.h"
#include "storage/smgr.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/resowner.h"
...
...
@@ -46,6 +47,9 @@ static int nextFreeLocalBuf = 0;
static
HTAB
*
LocalBufHash
=
NULL
;
static
void
InitLocalBuffers
(
void
);
/*
* LocalBufferAlloc -
* Find or create a local buffer for the given page of the given relation.
...
...
@@ -66,6 +70,10 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr)
INIT_BUFFERTAG
(
newTag
,
reln
,
blockNum
);
/* Initialize local buffers if first request in this session */
if
(
LocalBufHash
==
NULL
)
InitLocalBuffers
();
/* See if the desired buffer already exists */
hresult
=
(
LocalBufferLookupEnt
*
)
hash_search
(
LocalBufHash
,
(
void
*
)
&
newTag
,
HASH_FIND
,
NULL
);
...
...
@@ -238,32 +246,18 @@ WriteLocalBuffer(Buffer buffer, bool release)
}
/*
* InitLocalBuffer -
* InitLocalBuffer
s
-
* init the local buffer cache. Since most queries (esp. multi-user ones)
* don't involve local buffers, we delay allocating actual memory for the
* buffers until we need them; just make the buffer headers here.
*/
void
InitLocalBuffer
(
void
)
static
void
InitLocalBuffer
s
(
void
)
{
int
nbufs
=
64
;
/* should be from a GUC var */
int
nbufs
=
num_temp_buffers
;
HASHCTL
info
;
int
i
;
/* Create the lookup hash table */
MemSet
(
&
info
,
0
,
sizeof
(
info
));
info
.
keysize
=
sizeof
(
BufferTag
);
info
.
entrysize
=
sizeof
(
LocalBufferLookupEnt
);
info
.
hash
=
tag_hash
;
LocalBufHash
=
hash_create
(
"Local Buffer Lookup Table"
,
nbufs
,
&
info
,
HASH_ELEM
|
HASH_FUNCTION
);
if
(
!
LocalBufHash
)
elog
(
ERROR
,
"could not initialize local buffer hash table"
);
/* Allocate and zero buffer headers and auxiliary arrays */
LocalBufferDescriptors
=
(
BufferDesc
*
)
MemoryContextAllocZero
(
TopMemoryContext
,
...
...
@@ -291,6 +285,20 @@ InitLocalBuffer(void)
buf
->
buf_id
=
-
i
-
2
;
}
/* Create the lookup hash table */
MemSet
(
&
info
,
0
,
sizeof
(
info
));
info
.
keysize
=
sizeof
(
BufferTag
);
info
.
entrysize
=
sizeof
(
LocalBufferLookupEnt
);
info
.
hash
=
tag_hash
;
LocalBufHash
=
hash_create
(
"Local Buffer Lookup Table"
,
nbufs
,
&
info
,
HASH_ELEM
|
HASH_FUNCTION
);
if
(
!
LocalBufHash
)
elog
(
ERROR
,
"could not initialize local buffer hash table"
);
/* Initialization done, mark buffers allocated */
NLocBuffer
=
nbufs
;
}
...
...
src/backend/utils/init/postinit.c
View file @
91728fa2
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.14
3 2005/03/18 16:16:09
tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.14
4 2005/03/19 23:27:06
tgl Exp $
*
*
*-------------------------------------------------------------------------
...
...
@@ -257,7 +257,6 @@ BaseInit(void)
/* Do local initialization of storage and buffer managers */
smgrinit
();
InitBufferPoolAccess
();
InitLocalBuffer
();
}
...
...
src/backend/utils/misc/guc.c
View file @
91728fa2
...
...
@@ -10,7 +10,7 @@
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.25
5 2005/03/13 09:36:31 neilc
Exp $
* $PostgreSQL: pgsql/src/backend/utils/misc/guc.c,v 1.25
6 2005/03/19 23:27:07 tgl
Exp $
*
*--------------------------------------------------------------------
*/
...
...
@@ -104,6 +104,7 @@ static const char *assign_log_error_verbosity(const char *newval, bool doit,
GucSource
source
);
static
const
char
*
assign_log_statement
(
const
char
*
newval
,
bool
doit
,
GucSource
source
);
static
const
char
*
show_num_temp_buffers
(
void
);
static
bool
assign_phony_autocommit
(
bool
newval
,
bool
doit
,
GucSource
source
);
static
const
char
*
assign_custom_variable_classes
(
const
char
*
newval
,
bool
doit
,
GucSource
source
);
...
...
@@ -144,9 +145,10 @@ bool default_with_oids = false;
int
log_min_error_statement
=
PANIC
;
int
log_min_messages
=
NOTICE
;
int
client_min_messages
=
NOTICE
;
int
log_min_duration_statement
=
-
1
;
int
num_temp_buffers
=
1000
;
char
*
ConfigFileName
;
char
*
HbaFileName
;
char
*
IdentFileName
;
...
...
@@ -966,6 +968,15 @@ static struct config_int ConfigureNamesInt[] =
1000
,
16
,
INT_MAX
/
BLCKSZ
,
NULL
,
NULL
},
{
{
"temp_buffers"
,
PGC_USERSET
,
RESOURCES_MEM
,
gettext_noop
(
"Sets the maximum number of temporary buffers used by each session."
),
NULL
},
&
num_temp_buffers
,
1000
,
100
,
INT_MAX
/
BLCKSZ
,
NULL
,
show_num_temp_buffers
},
{
{
"port"
,
PGC_POSTMASTER
,
CONN_AUTH_SETTINGS
,
gettext_noop
(
"Sets the TCP port the server listens on."
),
...
...
@@ -5496,6 +5507,19 @@ assign_log_statement(const char *newval, bool doit, GucSource source)
return
newval
;
/* OK */
}
static
const
char
*
show_num_temp_buffers
(
void
)
{
/*
* We show the GUC var until local buffers have been initialized,
* and NLocBuffer afterwards.
*/
static
char
nbuf
[
32
];
sprintf
(
nbuf
,
"%d"
,
NLocBuffer
?
NLocBuffer
:
num_temp_buffers
);
return
nbuf
;
}
static
bool
assign_phony_autocommit
(
bool
newval
,
bool
doit
,
GucSource
source
)
{
...
...
src/backend/utils/misc/postgresql.conf.sample
View file @
91728fa2
...
...
@@ -74,6 +74,7 @@
# - Memory -
#shared_buffers = 1000 # min 16, at least max_connections*2, 8KB each
#temp_buffers = 1000 # min 100, 8KB each
#work_mem = 1024 # min 64, size in KB
#maintenance_work_mem = 16384 # min 1024, size in KB
#max_stack_depth = 2048 # min 100, size in KB
...
...
src/bin/psql/tab-complete.c
View file @
91728fa2
...
...
@@ -3,7 +3,7 @@
*
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.12
1 2005/01/23 15:58:50 momjian
Exp $
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.12
2 2005/03/19 23:27:08 tgl
Exp $
*/
/*----------------------------------------------------------------------
...
...
@@ -594,6 +594,7 @@ psql_completion(char *text, int start, int end)
"superuser_reserved_connections"
,
"syslog_facility"
,
"syslog_ident"
,
"temp_buffers"
,
"TimeZone"
,
"trace_notify"
,
"transform_null_equals"
,
...
...
src/include/storage/bufmgr.h
View file @
91728fa2
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.9
1 2005/03/18 16:16:09
tgl Exp $
* $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.9
2 2005/03/19 23:27:10
tgl Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -157,7 +157,6 @@ extern void BufmgrCommit(void);
extern
void
BufferSync
(
void
);
extern
void
BgBufferSync
(
void
);
extern
void
InitLocalBuffer
(
void
);
extern
void
AtProcExit_LocalBuffers
(
void
);
/* in freelist.c */
...
...
src/include/utils/guc.h
View file @
91728fa2
...
...
@@ -7,7 +7,7 @@
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
*
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.5
8 2005/01/01 05:43:09 momjian
Exp $
* $PostgreSQL: pgsql/src/include/utils/guc.h,v 1.5
9 2005/03/19 23:27:11 tgl
Exp $
*--------------------------------------------------------------------
*/
#ifndef GUC_H
...
...
@@ -126,6 +126,8 @@ extern int log_min_messages;
extern
int
client_min_messages
;
extern
int
log_min_duration_statement
;
extern
int
num_temp_buffers
;
extern
char
*
ConfigFileName
;
extern
char
*
HbaFileName
;
extern
char
*
IdentFileName
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment