From 92cd1ad639bf07d9395db46faecbbe73ac7d59ef Mon Sep 17 00:00:00 2001 From: Artemiy Ryabinkov Date: Mon, 29 Jul 2019 21:19:36 +0300 Subject: [PATCH] Set 8KB as default size of ChunkReader buffer Signed-off-by: Artemiy Ryabinkov --- chunkreader/chunkreader.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/chunkreader/chunkreader.go b/chunkreader/chunkreader.go index f8d437b2..5c36292d 100644 --- a/chunkreader/chunkreader.go +++ b/chunkreader/chunkreader.go @@ -28,7 +28,11 @@ func NewChunkReader(r io.Reader) *ChunkReader { func NewChunkReaderEx(r io.Reader, options Options) (*ChunkReader, error) { if options.MinBufLen == 0 { - options.MinBufLen = 4096 + // By historical reasons Postgres currently has 8KB send buffer inside, + // so here we want to have at least the same size buffer. + // @see https://github.com/postgres/postgres/blob/249d64999615802752940e017ee5166e726bc7cd/src/backend/libpq/pqcomm.c#L134 + // @see https://www.postgresql.org/message-id/0cdc5485-cb3c-5e16-4a46-e3b2f7a41322%40ya.ru + options.MinBufLen = 8192 } return &ChunkReader{