aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-02-18 09:52:02 +0900
committerMichael Paquier <michael@paquier.xyz>2019-02-18 09:52:02 +0900
commit0dd6ff0ac8482f753405c5bdb091d2a8adc58e75 (patch)
tree2470b0c901e8bfde30a7b99dfea2f6ec93843857
parent0b55aaacec313c309e21f63d9ff5733c3f8ab813 (diff)
downloadpostgresql-0dd6ff0ac8482f753405c5bdb091d2a8adc58e75.tar.gz
postgresql-0dd6ff0ac8482f753405c5bdb091d2a8adc58e75.zip
Avoid some unnecessary block reads in WAL reader
When reading a new page internally and depending on the way the WAL reader facility gets used by plugins, the current implementation of the WAL reader may finish by reading a block multiple times while it is not actually necessary as the requested data length may be equal to what has been already read. This can happen for any size, but is more likely to happen at the end of a page. This can cause performance penalties in plugins which rely on the block reads to be purely sequential, zlib not liking backward reads for example. The new behavior also shaves some cycles when doing recovery. Author: Arthur Zakirov Reviewed-by: Andrey Lepikhov, Michael Paquier, Grigory Smolkin Discussion: https://postgr.es/m/2ddf4a32-517e-d6f4-d992-4a63b6035bfd@postgrespro.ru
-rw-r--r--src/backend/access/transam/xlogreader.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c
index 69b6226f8f1..cbc7e4e7ead 100644
--- a/src/backend/access/transam/xlogreader.c
+++ b/src/backend/access/transam/xlogreader.c
@@ -536,7 +536,7 @@ ReadPageInternal(XLogReaderState *state, XLogRecPtr pageptr, int reqLen)
/* check whether we have all the requested data already */
if (targetSegNo == state->readSegNo && targetPageOff == state->readOff &&
- reqLen < state->readLen)
+ reqLen <= state->readLen)
return state->readLen;
/*