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

Commit3e63e84

Browse files
committed
When using the WAL-logged CREATE DATABASE strategy, bulk extend.
This should improve performance, and was suggested by Andres Freund.Back-patch to v15 to keep the code consistent across branches.Dilip KumarDiscussion:http://postgr.es/m/C3458199-FEDD-4356-865A-08DFAA5D4065@anarazel.deDiscussion:http://postgr.es/m/CAFiTN-sJ0vVpJrZ=R5M+g7Tr8=NN4wKOtrqOcDEsfFfnZgivVA@mail.gmail.com
1 parent27f1774 commit3e63e84

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3712,6 +3712,7 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator,
37123712
booluse_wal;
37133713
BlockNumbernblocks;
37143714
BlockNumberblkno;
3715+
PGAlignedBlockbuf;
37153716
BufferAccessStrategybstrategy_src;
37163717
BufferAccessStrategybstrategy_dst;
37173718

@@ -3730,6 +3731,14 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator,
37303731
if (nblocks==0)
37313732
return;
37323733

3734+
/*
3735+
* Bulk extend the destination relation of the same size as the source
3736+
* relation before starting to copy block by block.
3737+
*/
3738+
memset(buf.data,0,BLCKSZ);
3739+
smgrextend(smgropen(dstlocator,InvalidBackendId),forkNum,nblocks-1,
3740+
buf.data, true);
3741+
37333742
/* This is a bulk operation, so use buffer access strategies. */
37343743
bstrategy_src=GetAccessStrategy(BAS_BULKREAD);
37353744
bstrategy_dst=GetAccessStrategy(BAS_BULKWRITE);
@@ -3747,7 +3756,7 @@ RelationCopyStorageUsingBuffer(RelFileLocator srclocator,
37473756
srcPage=BufferGetPage(srcBuf);
37483757

37493758
/* Use P_NEW to extend the destination relation. */
3750-
dstBuf=ReadBufferWithoutRelcache(dstlocator,forkNum,P_NEW,
3759+
dstBuf=ReadBufferWithoutRelcache(dstlocator,forkNum,blkno,
37513760
RBM_NORMAL,bstrategy_dst,
37523761
permanent);
37533762
LockBuffer(dstBuf,BUFFER_LOCK_EXCLUSIVE);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp