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

Commit5df307c

Browse files
committed
Restructure local-buffer handling per recent pghackers discussion.
The local buffer manager is no longer used for newly-created relations(unless they are TEMP); a new non-TEMP relation goes through the sharedbufmgr and thus will participate normally in checkpoints. But TEMP relationsuse the local buffer manager throughout their lifespan. Also, operationsin TEMP relations are not logged in WAL, thus improving performance.Since it's no longer necessary to fsync relations as they move out of thelocal buffers into shared buffers, quite a lot of smgr.c/md.c/fd.c codeis no longer needed and has been removed: there's no concept of a dirtyrelation anymore in md.c/fd.c, and we never fsync anything but WAL.Still TODO: improve local buffer management algorithms so that it wouldbe reasonable to increase NLocBuffer.
1 parent35cd432 commit5df307c

File tree

28 files changed

+543
-955
lines changed

28 files changed

+543
-955
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.143 2002/07/30 16:08:33momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.144 2002/08/06 02:36:33tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1155,6 +1155,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
11551155
pgstat_count_heap_insert(&relation->pgstat_info);
11561156

11571157
/* XLOG stuff */
1158+
if (!relation->rd_istemp)
11581159
{
11591160
xl_heap_insertxlrec;
11601161
xl_heap_headerxlhdr;
@@ -1204,6 +1205,12 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid)
12041205
PageSetLSN(page,recptr);
12051206
PageSetSUI(page,ThisStartUpID);
12061207
}
1208+
else
1209+
{
1210+
/* No XLOG record, but still need to flag that XID exists on disk */
1211+
MyXactMadeTempRelUpdate= true;
1212+
}
1213+
12071214
END_CRIT_SECTION();
12081215

12091216
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
@@ -1323,12 +1330,15 @@ heap_delete(Relation relation, ItemPointer tid,
13231330
}
13241331

13251332
START_CRIT_SECTION();
1333+
13261334
/* store transaction information of xact deleting the tuple */
13271335
tp.t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
13281336
HEAP_XMAX_INVALID |HEAP_MARKED_FOR_UPDATE);
13291337
HeapTupleHeaderSetXmax(tp.t_data,GetCurrentTransactionId());
13301338
HeapTupleHeaderSetCmax(tp.t_data,cid);
1339+
13311340
/* XLOG stuff */
1341+
if (!relation->rd_istemp)
13321342
{
13331343
xl_heap_deletexlrec;
13341344
XLogRecPtrrecptr;
@@ -1351,12 +1361,17 @@ heap_delete(Relation relation, ItemPointer tid,
13511361
PageSetLSN(dp,recptr);
13521362
PageSetSUI(dp,ThisStartUpID);
13531363
}
1364+
else
1365+
{
1366+
/* No XLOG record, but still need to flag that XID exists on disk */
1367+
MyXactMadeTempRelUpdate= true;
1368+
}
1369+
13541370
END_CRIT_SECTION();
13551371

13561372
LockBuffer(buffer,BUFFER_LOCK_UNLOCK);
13571373

13581374
#ifdefTUPLE_TOASTER_ACTIVE
1359-
13601375
/*
13611376
* If the relation has toastable attributes, we need to delete no
13621377
* longer needed items there too. We have to do this before
@@ -1659,6 +1674,7 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
16591674
oldtup.t_data->t_ctid=newtup->t_self;
16601675

16611676
/* XLOG stuff */
1677+
if (!relation->rd_istemp)
16621678
{
16631679
XLogRecPtrrecptr=log_heap_update(relation,buffer,oldtup.t_self,
16641680
newbuf,newtup, false);
@@ -1671,6 +1687,11 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
16711687
PageSetLSN(BufferGetPage(buffer),recptr);
16721688
PageSetSUI(BufferGetPage(buffer),ThisStartUpID);
16731689
}
1690+
else
1691+
{
1692+
/* No XLOG record, but still need to flag that XID exists on disk */
1693+
MyXactMadeTempRelUpdate= true;
1694+
}
16741695

16751696
END_CRIT_SECTION();
16761697

@@ -1927,6 +1948,9 @@ log_heap_clean(Relation reln, Buffer buffer, char *unused, int unlen)
19271948
XLogRecPtrrecptr;
19281949
XLogRecDatardata[3];
19291950

1951+
/* Caller should not call me on a temp relation */
1952+
Assert(!reln->rd_istemp);
1953+
19301954
xlrec.node=reln->rd_node;
19311955
xlrec.block=BufferGetBlockNumber(buffer);
19321956
rdata[0].buffer=InvalidBuffer;
@@ -1978,6 +2002,9 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
19782002
Pagepage=BufferGetPage(newbuf);
19792003
uint8info= (move) ?XLOG_HEAP_MOVE :XLOG_HEAP_UPDATE;
19802004

2005+
/* Caller should not call me on a temp relation */
2006+
Assert(!reln->rd_istemp);
2007+
19812008
xlrec.target.node=reln->rd_node;
19822009
xlrec.target.tid=from;
19832010
xlrec.newtid=newtup->t_self;
@@ -2012,7 +2039,8 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from,
20122039
xid[0]=HeapTupleHeaderGetXmax(newtup->t_data);
20132040
xid[1]=HeapTupleHeaderGetXmin(newtup->t_data);
20142041
memcpy((char*)&xlhdr+hsize,
2015-
(char*)xid,2*sizeof(TransactionId));
2042+
(char*)xid,
2043+
2*sizeof(TransactionId));
20162044
hsize+=2*sizeof(TransactionId);
20172045
}
20182046
rdata[2].buffer=newbuf;

‎src/backend/access/heap/hio.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Id: hio.c,v 1.45 2002/06/20 20:29:25 momjian Exp $
11+
* $Id: hio.c,v 1.46 2002/08/06 02:36:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -102,6 +102,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
102102
SizepageFreeSpace;
103103
BlockNumbertargetBlock,
104104
otherBlock;
105+
boolneedLock;
105106

106107
len=MAXALIGN(len);/* be conservative */
107108

@@ -231,9 +232,12 @@ RelationGetBufferForTuple(Relation relation, Size len,
231232
*
232233
* We have to use a lock to ensure no one else is extending the rel at
233234
* the same time, else we will both try to initialize the same new
234-
* page.
235+
* page. We can skip locking for new or temp relations, however,
236+
* since no one else could be accessing them.
235237
*/
236-
if (!relation->rd_myxactonly)
238+
needLock= !(relation->rd_isnew||relation->rd_istemp);
239+
240+
if (needLock)
237241
LockPage(relation,0,ExclusiveLock);
238242

239243
/*
@@ -249,7 +253,7 @@ RelationGetBufferForTuple(Relation relation, Size len,
249253
* Release the file-extension lock; it's now OK for someone else to
250254
* extend the relation some more.
251255
*/
252-
if (!relation->rd_myxactonly)
256+
if (needLock)
253257
UnlockPage(relation,0,ExclusiveLock);
254258

255259
/*

‎src/backend/access/heap/tuptoaster.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.33 2002/07/20 05:16:56 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.34 2002/08/06 02:36:33 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -915,7 +915,7 @@ toast_save_datum(Relation rel, Datum value)
915915
*/
916916
idxres=index_insert(toastidx,t_values,t_nulls,
917917
&(toasttup->t_self),
918-
toastrel,toastidx->rd_uniqueindex);
918+
toastrel,toastidx->rd_index->indisunique);
919919
if (idxres==NULL)
920920
elog(ERROR,"Failed to insert index entry for TOAST tuple");
921921

‎src/backend/access/nbtree/nbtinsert.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.94 2002/07/02 05:48:44 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.95 2002/08/06 02:36:33 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -623,8 +623,11 @@ _bt_insertuple(Relation rel, Buffer buf,
623623
BTPageOpaquepageop= (BTPageOpaque)PageGetSpecialPointer(page);
624624

625625
START_CRIT_SECTION();
626+
626627
_bt_pgaddtup(rel,page,itemsz,btitem,newitemoff,"page");
628+
627629
/* XLOG stuff */
630+
if (!rel->rd_istemp)
628631
{
629632
xl_btree_insertxlrec;
630633
uint8flag=XLOG_BTREE_INSERT;
@@ -866,6 +869,9 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
866869
* NO ELOG(ERROR) till right sibling is updated.
867870
*/
868871
START_CRIT_SECTION();
872+
873+
/* XLOG stuff */
874+
if (!rel->rd_istemp)
869875
{
870876
xl_btree_splitxlrec;
871877
intflag= (newitemonleft) ?
@@ -891,7 +897,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright,
891897
BlockIdSet(&(xlrec.rightblk),ropaque->btpo_next);
892898

893899
/*
894-
*Dirrect access to page is not good but faster - we should
900+
*Direct access to page is not good but faster - we should
895901
* implement some new func in page API.
896902
*/
897903
xlrec.leftlen= ((PageHeader)leftpage)->pd_special-
@@ -1352,6 +1358,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
13521358
(metad->btm_level)++;
13531359

13541360
/* XLOG stuff */
1361+
if (!rel->rd_istemp)
13551362
{
13561363
xl_btree_newrootxlrec;
13571364
XLogRecPtrrecptr;
@@ -1366,7 +1373,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
13661373
rdata[0].next=&(rdata[1]);
13671374

13681375
/*
1369-
*Dirrect access to page is not good but faster - we should
1376+
*Direct access to page is not good but faster - we should
13701377
* implement some new func in page API.
13711378
*/
13721379
rdata[1].buffer=InvalidBuffer;
@@ -1388,6 +1395,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
13881395
PageSetLSN(rpage,recptr);
13891396
PageSetSUI(rpage,ThisStartUpID);
13901397
}
1398+
13911399
END_CRIT_SECTION();
13921400

13931401
/* write and let go of metapage buffer */

‎src/backend/access/nbtree/nbtpage.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.57 2002/06/20 20:29:25 momjian Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.58 2002/08/06 02:36:33 tgl Exp $
1313
*
1414
*NOTES
1515
* Postgres btree pages look like ordinary relation pages.The opaque
@@ -173,6 +173,7 @@ _bt_getroot(Relation rel, int access)
173173
rootopaque->btpo_flags |= (BTP_LEAF |BTP_ROOT);
174174

175175
/* XLOG stuff */
176+
if (!rel->rd_istemp)
176177
{
177178
xl_btree_newrootxlrec;
178179
XLogRecPtrrecptr;
@@ -187,7 +188,8 @@ _bt_getroot(Relation rel, int access)
187188
rdata.next=NULL;
188189

189190
recptr=XLogInsert(RM_BTREE_ID,
190-
XLOG_BTREE_NEWROOT |XLOG_BTREE_LEAF,&rdata);
191+
XLOG_BTREE_NEWROOT |XLOG_BTREE_LEAF,
192+
&rdata);
191193

192194
PageSetLSN(rootpage,recptr);
193195
PageSetSUI(rootpage,ThisStartUpID);
@@ -457,6 +459,7 @@ _bt_itemdel(Relation rel, Buffer buf, ItemPointer tid)
457459
PageIndexTupleDelete(page,offno);
458460

459461
/* XLOG stuff */
462+
if (!rel->rd_istemp)
460463
{
461464
xl_btree_deletexlrec;
462465
XLogRecPtrrecptr;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp