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.96) (envelope-from ) id 1w4xWU-002kB9-3B for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 08:54:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w4xWS-005RLy-19 for pgsql-hackers@arkaria.postgresql.org; Tue, 24 Mar 2026 08:54:00 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w4xWR-005RLp-2x for pgsql-hackers@lists.postgresql.org; Tue, 24 Mar 2026 08:54:00 +0000 Received: from mail-lf1-x12b.google.com ([2a00:1450:4864:20::12b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w4xWP-00000000lQX-2BKU for pgsql-hackers@postgresql.org; Tue, 24 Mar 2026 08:53:58 +0000 Received: by mail-lf1-x12b.google.com with SMTP id 2adb3069b0e04-5a1443780c4so4963594e87.0 for ; Tue, 24 Mar 2026 01:53:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1774342436; cv=none; d=google.com; s=arc-20240605; b=HCIZMJULV2FyybdBoSF8rK3Fs/XkQvqct/fpc8kd4og0VIWofn5kWFlcN24Dzu2ZdO UpxOM41Rrnd+8U6YTcRKntN+LNAg3Ikb3hv/7XE5+ytRLYnKrKwCTk2tNLK+z/EPcVx7 iBrBNl+A+wnUlqa8oq3gA2ZHOvGMSYQAxHXK8SudhS/xTxZUJ07lPabjjPiFuo6RHwCp R1mLQdFCcX3yNVTgiZl88o4CAMDCZ/3kUB+SqTIoDKC4mVwdQ4jup+GDr7S/9cRJ8jTp 1Px9EcLMT+Mdjx97Insf1zyM9QQb0Hqqsw5lMzTdl3VaIl0oUR4gGthOdyFqJ/CxMOL4 jLTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DjCgxiMlOvcxPICsForJ1lCVKbSOKFVydMRSgxP/yvw=; fh=SKdsTEYQhyyrYWVJ48TlyoNjKM3xPsF3n7jfcbG38N4=; b=YMorhng0vHQ8SOCqSyZGzXkhTyL0acNJHuCl9Wwkj602JX+z5f/2TjIvEmLZBdZ8+s SZcYDoES8ORsBAHuuiSm7tYeUztKZ2OPz/v8bd7GPR6ei40DskBDPOfXjxW7Ob6obV1I JjUYZymtzRV4rPelggzOtwO8+8dUmwHGgijGJmOb8Vl6+1oOg2TQ6Klkp6TuK/TtWBMI JMJLXWLAM5EOcauw1CcVlaBVD3jSxkceWdGyDKzW0/X8rjPR+LSWtgr5ah8EpAkqor6X 5Hy6eGmIO2RdDTSP/Wrx2DXenQtqPv9dxPerHwlA0xwXTsmkB/32G8iuI+kW1vFnOWFe SR5Q==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1774342436; x=1774947236; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DjCgxiMlOvcxPICsForJ1lCVKbSOKFVydMRSgxP/yvw=; b=Ad1ReLK0p5WwpARdZePYfrTGS2ofh2wC3KSsdSsOxW5JwPugAuEPcxotytsKi6i82n 3uYIpF+SQt3Bg9o6FnLPuqRgQAKdzBYthO44Bi38pCnyr1KAyom3nNM9bIAMXGy18et2 b7JGHSbnnrSiC+PX7LYZdnJC1CI5C1N+krgQSgGTb+i4x0XDiG0e4KkMqHCdkxfolP/T KS3UrATdr6azrvHmphOAdG9XbDiyW1hWc0+JNndMlk/NkuKlyfgjl7IMQ2M7Wt4CT/B1 tCaysbrXhqR1mN9AjmMJH1gCXdtsdkSLmRGLn+k+eC9eQqEgzSG9l0nLEIb3WubIMgGP TwAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774342436; x=1774947236; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DjCgxiMlOvcxPICsForJ1lCVKbSOKFVydMRSgxP/yvw=; b=aZ3qZQFH6P/aJinx02v8d+Pym6j1KqfXDvkLwEIQpd3RjmConkxHEC+zA5RKy/IXLI 4ogIGo1eSBlsT9EUJYOzF3VHVxM4BzjeodQn5aS8t2XhzshPVP9K6pvcjc57pgTW62gc rfUCra/+Xg6nxCGymHnVp+KV9Pk24CdCogWqB9pCtU5iGlW1TY21hdNI3NfDLd4WdPWE xkRObPOGNuK3baMC0cDHO0YHdJCCX90SB2n4Watgi3lipcgwcfEdnl2hpexg+Ln80haK cv3KcZZstq42ge6w9ZCzCQp2xPFmezl3PJy3K2zx1FKqf5kvy6Uj6oBr+iKWLGgYInXJ Cakg== X-Forwarded-Encrypted: i=1; AJvYcCXihIqv2IowT8lLakttRB9B8oeqAX/R4C8KvM693Ao3yQEeF+HUgN/fFVwnkMNeZXXm4b4i7rlnVoxlkNcF@postgresql.org X-Gm-Message-State: AOJu0Yz+ULnJMbaHC6TRYzRq4PVADtcBmLjzMbMLNjblyLZm0Ln56ziv Ydky2UR/vns/LRWTBgfydMF6n/vwiuTetwqe2gA9Zpgdk1ACQQr2udB61Pj2P0XXepnDHWJugu4 7YhH04wpQnw0wShs8DwK6QBsM2DA/53SaLtqlEM2P X-Gm-Gg: ATEYQzyiQiavwr6b7CietUQ5fbC8wy+hRNrJbNxP+056/Z4rWAUAik89jPGJVp15YgA ywEBE4OaWlDUYXtDKF5slU4rRPE4mdBGJU8rW4Ou0SvW7fMdd3PqegbAL+erI+bLc5jCcLD+WIo L7XZqsJwXReO0TB9BWQVIfVExBYuh3xldWCxfMcSahJWR+Pr+yezAom8EQhuGUDfsEwxbu4wq2v ZfOZwLDEK9cBM+XTwyBUDY/f3ptKXqa1ooE0spFzobBb8ZtAhmoV6gjwK7qQHBBJcm6+86fkbP9 OdF3Clq3aMad5rvTNDPYcfeDB3Hf0544uj7LB/cI3I0KzEqRWBTg9mT+AwtOOtn8HMo= X-Received: by 2002:a05:651c:150c:b0:38a:78dc:844f with SMTP id 38308e7fff4ca-38c32931156mr7629651fa.13.1774342435554; Tue, 24 Mar 2026 01:53:55 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jakub Wartak Date: Tue, 24 Mar 2026 09:53:44 +0100 X-Gm-Features: AaiRm529TazOubGqgDhqeHEaPxzv7QiU5YfDlTmzYpkgjBC0l9fHEpUS8UDELbs Message-ID: Subject: Re: log XLogPrefetch stats at end of recovery To: Lakshmi N , Thomas Munro Cc: Bharath Rupireddy , SATYANARAYANA NARLAPURAM , pgsql-hackers@postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, Mar 24, 2026 at 9:28=E2=80=AFAM Lakshmi N = wrote: > > Hi all, > > Thank you for your feedback. Please see the attached patch. > > On Mon, Mar 23, 2026 at 4:30=E2=80=AFAM Jakub Wartak wrote: >> >> On Sun, Mar 22, 2026 at 1:43=E2=80=AFAM Bharath Rupireddy >> wrote: >> >> Hi, >> >> > On Sat, Mar 21, 2026 at 1:16=E2=80=AFAM SATYANARAYANA NARLAPURAM >> > wrote: >> > > >> > > > While investigating a long recovery, I noticed that XLogPrefetch s= tats were not logged at the end of recovery. This log message will be usefu= l to understand how effective XLogPrefetch was during recovery. Adding a pa= tch to address this. >> > > >> > > Applied this patch and validated the log message. This log message a= ppears to be useful to me, particularly while doing fleet wide analysis. >> > > >> > > 2026-03-20 23:33:13.756 PDT [2265441] LOG: XLogPrefetcher stats: pr= efetch=3D14, hit=3D6, skip_init=3D5, skip_new=3D28, skip_fpw=3D18, skip_rep= =3D996 >> > >> > This looks useful to understand how the prefetch helped during long re= coveries. >> > >> > > I am wondering if we can periodically log this in standby mode as we= ll, not just before promoting? >> > >> > Timer-based startup progress messaging allows logging such things >> > (ereport_startup_progress API). There was an attempt to enable "redo >> > in progress" for standbys, but that seemed to flood the standby logs >> > even at the default progress interval of 10 sec. >> > >> > Having said that, the prefetcher stats could be added to the existing >> > ereport_startup_progress("redo in progress xxx") message that works >> > for crash recoveries=E2=80=94however, I don't prefer doing a bunch of = atomic >> > reads every progress interval of 10 sec. >> >> > Therefore, logging at the end of recovery looks good to me. >> >> +1 from me too to only of logging at the end of recovery (so -1 to loggi= ng >> every now and then). If someone is interested in current state (or progr= ess >> over time) I think he can query pg_stat_recovery_prefetch view already, = even >> today, right? >> >> > I reviewed the patch. I have the following comment: >> > >> > + elog(LOG, "XLogPrefetcher stats: prefetch=3D%lu, hit=3D%lu, >> > skip_init=3D%lu, skip_new=3D%lu, skip_fpw=3D%lu, skip_rep=3D%lu", >> > >> > XLogPrefetcher is an internal data structure name, how about "redo >> > prefetch stats: xxxx" to be consistent with other redo log messages? >> >> +1 > > > please find the attached patch addressing this. Hi Lakshmi, The pg_stat_get_recovery_prefetch view has 3 additional columns, but they a= re showing current situation, maybe this $patch could be enhanced so that it a= lso calculates averages for some of them? I mean perhaps not just hit ratio wou= ld be nice, but also the e.g. __average__ wal distance or average look ahead (block distance). I'm not sure maybe please also wait for input from others if they find it a good idea or not. Also if we are adding such pretty cryptic fields as "skip_fpw" to log, we would need some place in documentaiton to explain their meaining probably. monitoring.sgml already explains them, so maybe just link to that. I mean if you look what we have today (below), they are little less crypting and have different format, not "skip_fpw=3D123" but more like "17 removed" so maybe "17 skipped due to FPW". Maybe redo done at 0/75C7B290 system usage: CPU: user: 1.02 s, system: 0.51 s, elapsed: 1.53 s checkpoint complete: end-of-recovery fast wait: wrote 16289 buffers (99.4%), wrote 3 SLRU buffers; 0 WAL file(s) added, 17 removed, 0 recycled; write=3D0.049 s, sync=3D0.191 s, total=3D0.264 s; sync files=3D10= , longest=3D0.187 s, average=3D0.020 s; distance=3D287186 kB, estimate=3D2871= 86 kB; lsn=3D0/75C7B2C8, redo lsn=3D0/75C7B2C8 so instead of like: redo prefetch stats: prefetch=3D%lu, hit=3D%lu, skip_init=3D%lu, skip_new=3D%lu, skip_fpw=3D%lu, skip_rep=3D%lu" something like below ones: redo prefetch stats: done %lu prefetches, %lu hit, %lu zero-initated, .. redo prefetch stats: done %lu prefetches, (%d% hit ratio), %lu zero-initated, .. or something like that -J.