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 1u27ea-00DKWP-N5 for pgsql-general@arkaria.postgresql.org; Tue, 08 Apr 2025 12:02:08 +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 1u27eZ-008AzI-4b for pgsql-general@arkaria.postgresql.org; Tue, 08 Apr 2025 12:02:07 +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 1u27eY-008Az6-QB for pgsql-general@lists.postgresql.org; Tue, 08 Apr 2025 12:02:07 +0000 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u27eW-0047t2-1p for pgsql-general@lists.postgresql.org; Tue, 08 Apr 2025 12:02:06 +0000 Received: by mail-oi1-x230.google.com with SMTP id 5614622812f47-3fa6c54cdb2so4448710b6e.3 for ; Tue, 08 Apr 2025 05:02:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744113723; x=1744718523; darn=lists.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=YdbJZjUaCbmVMUzDg3P2gX+lXdZ1y4I7vmbXcYhQSO8=; b=PiiBnCUynVwwkxofAeqKgR0FD3vrirVeIdNCUcUa8xVIgxK4aHgvqa89lhKw7l2SAK BiMGCjk5AtV3caGEXFIYnzEN6co4I2IPG8zM3idk7rZNci3bNQN27oASCjNqisFamVM3 nEaLfZXvX0NGu0tqlC8ntj8v0L1xaUn9FCJ44kouEBTVw6tVmKTwNxPToWT4NVx0rEN4 sW+R0G0feAEz60zb9znwsl17rD+vXTPm+sCkMQgSbMwUHoZlkrgW5Zv2M4q5lm6Idpa8 /yWy1aenwQL2gsWz8dXRVEZFI+ahBYNnVBe9QsvUVFxK6gwqLhzv7nmf3dE2iRRIE8v0 epUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744113723; x=1744718523; 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=YdbJZjUaCbmVMUzDg3P2gX+lXdZ1y4I7vmbXcYhQSO8=; b=XNV+Up9sgrxRQ5Kn+wRo/FeTU6ImucoEVz/aMes33lmkv2Ni97/JmmBYXfzw1wtsGt yt7Yy5QX5dBpI4xxHpqFfJrxzU+sjGBIWKbhF2iOg1ItFLGGCvV6pKH7oTteARZebHjx akRQNW7Se2Vn1agNJiBO0YDbk6jyZtioFgywsUVPItoofcE0Y6+O2Xu9gUJ6pGziIG/i YM2RMWRQgZ+FFm15TDMumwNOdsgAH97RddMcmi9kt+r7y09B2QTYWJa/cfpUi+RB7YwD np8d8MH7wesan9pzsL/98hZUAMZeL8ML4Xm5YSq7u8pTn8ISXDcRM5PnkdukzPrj7+IU oKmA== X-Gm-Message-State: AOJu0YyePP2k1ZVNyW45KWhsm8gVef2ZywXz1sEZMnbvnqOhBJtGTa0W u24Crkyz22YV18zmXEOmhBmEzPjQfX8oP1uMvA97T2jGeOxnumFyrH/geLdvw3r4b6ohTPwfZ7J U+i2U6ihx0blzYE2EkNMPlTLg9P25huNndUU= X-Gm-Gg: ASbGnctYQrjtwHc9C46y84m91+jwbX1wcUzBs1DYFMnhSxoDgnlfPxwvJpV6/NeJR/5 Txq0dhwDQr0M0xOn8BBZ+9oFm2H8Tv1zA74IOBMv7uQaKGgyqZW+ChR6zUl+i4Yhv6BYPz2HeFd azNLk/IU31R3XbX1iaruhLJX0gfw== X-Google-Smtp-Source: AGHT+IG7Oqgui3STzU7DIdgn5UtPsRG3GLstiQuqr75yxpjt69Yz3Hilu+OO+yIDUsrGoD6NxUQfBI4odNpjLAgZRFY= X-Received: by 2002:a05:6122:8288:b0:525:aecb:6306 with SMTP id 71dfb90a1353d-52765dc9a76mr10920147e0c.11.1744113712253; Tue, 08 Apr 2025 05:01:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kashif Zeeshan Date: Tue, 8 Apr 2025 17:01:38 +0500 X-Gm-Features: ATxdqUGOuHrBS8n6qN43uZaxYb1JDG0N_d3CJmIgphtlW8RZ5t_Tq7lzMIcMT8Q Message-ID: Subject: Re: Wal file query To: Atul Kumar Cc: pgsql-general Content-Type: multipart/alternative; boundary="0000000000004454f70632431eea" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004454f70632431eea Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Atul Start by looking at the current WAL LSN and insert LSN. The pg_current_wal_lsn is the location of the last write. The pg_current_wal_insert_lsn is the logical location and reflects data in the buffer that has not been written to disk. There is also a flush value that shows what has been written to durable storage. [postgres] # select pg_current_wal_lsn(), pg_current_wal_insert_lsn(); pg_current_wal_lsn | pg_current_wal_insert_lsn --------------------+--------------------------- 76/7D000000 | 76/7D000028 (1 row) Although you can guess the name of the WAL file based on the above output, it is best to use the pg_walfile_name function. [postgres] # select pg_walfile_name('76/7D000028'); pg_walfile_name -------------------------- 00000001000000760000007D (1 row) For details visit following link : https://www.crunchydata.com/blog/postgres-wal-files-and-sequuence-numbers Thanks Kashif Zeeshan On Tue, Apr 8, 2025 at 4:44=E2=80=AFPM Atul Kumar w= rote: > In streaming replication What is the way to check which "WAL file" is > currently in use in primary and in standby ? > > > Regards. > --0000000000004454f70632431eea Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi=C2=A0Atul

Start by looking at the cu= rrent WAL LSN and insert LSN. The pg_current_wal_lsn is the lo= cation of the last write. The pg_current_wal_insert_lsn is the logical location and reflects data in the buffer that has not=20 been written to disk. There is also a flush value that shows what has=20 been written to durable storage.
[postgres] # select pg_current_wal_lsn(), pg_current=
_wal_insert_lsn();
 pg_current_wal_lsn | pg_current_wal_insert_lsn
--------------------+---------------------------
 76/7D000000        | 76/7D000028
(1 row)
Although =
you can guess the name of the WAL file based on the above output, it is bes=
t to use the pg_walfile_name function.

[postgres] # select pg_walfile_name('76/7D000028');
     pg_walfile_name
--------------------------
 00000001000000760000007D
(1 row)
For det=
ails visit following link : https://www.crunchydata.com/blog/pos=
tgres-wal-files-and-sequuence-numbers

Thanks
Kashif Zeeshan
=

--0000000000004454f70632431eea--