On Thu, Feb 15, 2024 at 3:49 PM Nazir Bilal Yavuz <byavu...@gmail.com> wrote: > > > I'm wondering why the WALRead() callers are always reading XLOG_BLCKSZ > > despite knowing exactly how much to read. Is it to tell the OS to > > explicitly fetch the whole page from the disk? If yes, the OS will do > > that anyway because the page transfers from disk to OS page cache are > > always in terms of disk block sizes, no? > > I am curious about the same. The page size and disk block size could > be different,
Yes, they can be different, but.... (see below) > so the reason could be explicitly fetching the whole > page from the disk as you said. Upon OS page cache miss, the whole page (of disk block size) gets fetched from disk even if we just read 'count' bytes (< disk block size), no? This is my understanding about page transfers between disk and OS page cache. > Is this the reason or are there any > other benefits of always reading XLOG_BLCKSZ instead of reading the > sufficient part? I tried to search in older threads and code comments > but I could not find an explanation. FWIW, walsender for physical replication will just read as much as it wants to read which can range from WAL of size < XLOG_BLCKSZ to MAX_SEND_SIZE (XLOG_BLCKSZ * 16). I mean, it does not read the whole page of bytes XLOG_BLCKSZ when it wants to read < XLOG_BLCKSZ. -- Bharath Rupireddy PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com