Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uzauu-005Ik1-BR for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Sep 2025 13:12:48 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uzaut-007Dax-0K for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Sep 2025 13:12:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1uzaus-007Dap-NJ for pgsql-hackers@lists.postgresql.org; Fri, 19 Sep 2025 13:12:46 +0000 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uzauo-001hiw-34 for pgsql-hackers@postgresql.org; Fri, 19 Sep 2025 13:12:46 +0000 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-570d0c280e4so2433407e87.0 for ; Fri, 19 Sep 2025 06:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758287564; x=1758892364; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=6xtez4MAVUBx+9VRdk4jOEbvAkOU2T/1dEzc+DcVrg8=; b=gLLedL0wT3N9hkUnXGuSxZBamNQ1vK10LeMV1/YvUTXbk7WIRcQjR8vseBaaXEIriV /7NfnCKePyrznTiM/REeg07CSPmyI1ft/kJkOWFARU3tUL63xJ+yno7U34kyDpSMiwaq hLYDmYqSfJ/HvJvZkSX2CZj3+F/Lbym/EZf3e8BeduBRkRaJZZlmtTxMi4bT+Wb3bpiS 0jN14H6yKxYOPJqqObeMxjmuJn1eGaCHbzrHjOogoiqYWteivHhLdVcaeMgtAwG1S5yt 6J4UeM9oh0v96kznwrQfyKik5XnLADsPsAUOYpVo9FH4aGOGkRQDBo4eeQcjuiKjmzvw W2Lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758287564; x=1758892364; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6xtez4MAVUBx+9VRdk4jOEbvAkOU2T/1dEzc+DcVrg8=; b=rvl7tfHElyJXG4+IC35aC6uuca0q0kGEzrW4DaV9QWfQjQ+tHrTT5EcIaRAHD8rK4f xvtO7v9J2SXejFMfR3Ep1bcDBDJUzcmppAAP5uKrGi1IjGcfa6MuVq79WjJ6Bn1ZrGOE tg0HMBjArgAFgbSvgjKKkjvTb7WOzDnoZivd3BqeAr6T3Vi48eumyLB2FDgmE5u+LGGu R7YeFNMQCKfqL0dtAFl9MkNa8KrCi9KqpwRl3ASOdpXCnUT+w27h6zTjyFCrRbAtpxSi v8RkMDpQ1Z66piQTHKhUojrv2lRPN9xL5oGIE/O3R0pbXWSKXxGQyJ6XGRO7zNGdlqcW fDlw== X-Gm-Message-State: AOJu0YyJwZ8k29/w9rjXxI0z2QVec8UiIo7mQT9kyrJGUc4xQgCHLyzZ Xhnhw6qvdWZHPxJ0ByuWnAMfuV1dgIfEkwweaTRXWOhd/Yfj5oZJvni5z4sJGl2PO1lHZHvSYgt m3oFoPuPm5SOQZMEAXqspXTdGISofERM= X-Gm-Gg: ASbGncv4dM9A7j5A+ZtqX9u/91Wvd69imcfOJI2Hk3/dpPt5F8u5+q0MDxzM33HnCc2 mV7ce0Ojso2y7Wyiq/ygVVeb94c+b6qjJaoxq9JeoR9lDvUSTQhLYTI0r4hjOqZg5ErHGAVisP0 Yee6qikMwSNkYX8F4ThKfRAO2I8n+F+RK/MuTCfvoa3CRZWiozuW+u2fbn+inEN6+opahgV2UfU U8schv1XJ5K9j+Ys1oo2ZARgDUJ+FYMrdUSeMEQbz5MUVokMHPGxxWBnpGBijl4h/6AKAiVpnub QGt+mvKzXENcUo+pzQfSJw== X-Google-Smtp-Source: AGHT+IEcLK0wPZ9x8azDKxe/9IzmGbg7zVVCKNHRIqyfe5oiMuQggfejf7RiJCFVkLibgtIpQ0RBtSlVCqidLc+DcnI= X-Received: by 2002:a05:6512:3d19:b0:57a:8738:4d80 with SMTP id 2adb3069b0e04-57a87385082mr650444e87.21.1758287563472; Fri, 19 Sep 2025 06:12:43 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Rahila Syed Date: Fri, 19 Sep 2025 18:42:32 +0530 X-Gm-Features: AS18NWA_xPjAOgubvba0QuyFhX5k4oEGyT5wQo2LiAR0RvwVMjubATWIoM8J880 Message-ID: Subject: Re: Use WALReadFromBuffers in more places To: Bharath Rupireddy Cc: PostgreSQL-development Content-Type: multipart/alternative; boundary="000000000000a24b0b063f27391c" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000a24b0b063f27391c Content-Type: text/plain; charset="UTF-8" Hi Bharath, Hi, > > Commit 91f2cae7a4e that introduced WALReadFromBuffers only used it for > physical walsenders. It can also be used in more places benefitting > logical walsenders, backends running pg_walinspect and logical > decoding functions if the WAL is available in WAL buffers. I'm > attaching a 0001 patch for this. > > Thank you for working on this. It seems like a useful optimization. Do you have any information on how much this improves the performance of the new callers of WALReadFromBuffers? Regarding the v3 version of the patch, do you also intend to include other callers of WALRead, such as walsummarizer.c and pg_waldump.c? In WALReadFromBuffers, the buffer scan currently stops when it encounters a buffer that doesn't have the needed WAL page. However, it's possible to continue scanning past the missing page and find other relevant pages further along. By keeping track of which pages are missing, we could read only those specific pages from files, instead of reading everything after the first missing page. I am wondering if this was taken into account during the design of the function. Thank you, Rahila Syed --000000000000a24b0b063f27391c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Bharath,


Hi,

Commit 91f2cae7a4e that introduced WALReadFromBuffers only used it for
physical walsenders. It can also be used in more places benefitting
logical walsenders, backends running pg_walinspect and logical
decoding functions if the WAL is available in WAL buffers. I'm
attaching a 0001 patch for this.

=C2=A0
= Thank=C2=A0you for=C2=A0working on this. It seems like a useful optimizatio= n. Do you have any information
on how much this improves the performanc= e of the new callers of WALReadFromBuffers?

Regard= ing the v3 version of the patch, do you also intend to include other caller= s of WALRead,
such as walsummarizer.c and pg_waldump.c?=C2=A0=C2= =A0

In WALReadFromBuffers, the buffer scan currently stops wh= en it encounters a buffer that
doesn't have the needed WAL pa= ge. However, it's possible to continue scanning past the
missing pa= ge and find other relevant pages further along. By keeping track of which p= ages
are missing, we could read only those specific pages from files, i= nstead of reading everything
after the first missing page. I am wonderi= ng if this was taken into account during the design
of the function.=C2= =A0

Thank you,
Rahila Syed
--000000000000a24b0b063f27391c--