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

Commit576bb0f

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 parent9c4c22f commit576bb0f

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
@@ -3713,6 +3713,7 @@ RelationCopyStorageUsingBuffer(RelFileNode srcnode,
37133713
booluse_wal;
37143714
BlockNumbernblocks;
37153715
BlockNumberblkno;
3716+
PGAlignedBlockbuf;
37163717
BufferAccessStrategybstrategy_src;
37173718
BufferAccessStrategybstrategy_dst;
37183719

@@ -3731,6 +3732,14 @@ RelationCopyStorageUsingBuffer(RelFileNode srcnode,
37313732
if (nblocks==0)
37323733
return;
37333734

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

37503759
/* Use P_NEW to extend the destination relation. */
3751-
dstBuf=ReadBufferWithoutRelcache(dstnode,forkNum,P_NEW,
3760+
dstBuf=ReadBufferWithoutRelcache(dstnode,forkNum,blkno,
37523761
RBM_NORMAL,bstrategy_dst,
37533762
permanent);
37543763
LockBuffer(dstBuf,BUFFER_LOCK_EXCLUSIVE);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp