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 1vsfrr-00DKbK-0p for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Feb 2026 11:37:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vsfrq-00Fj86-0E for pgsql-hackers@arkaria.postgresql.org; Wed, 18 Feb 2026 11:37:18 +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 1vsfrp-00Fj7y-28 for pgsql-hackers@lists.postgresql.org; Wed, 18 Feb 2026 11:37:17 +0000 Received: from mail-lf1-x12d.google.com ([2a00:1450:4864:20::12d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vsfrl-00000001D0v-40pt for pgsql-hackers@lists.postgresql.org; Wed, 18 Feb 2026 11:37:15 +0000 Received: by mail-lf1-x12d.google.com with SMTP id 2adb3069b0e04-59b672f8ec4so4977785e87.1 for ; Wed, 18 Feb 2026 03:37:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1771414633; cv=none; d=google.com; s=arc-20240605; b=IlnisImGHd1zEbbE9uLJRfK9XuHDlq1IYf2bMDnilWktzOrws45u4YmMk/s7bEcCR2 MNMLxF1a4scTsGP+g0UaMQKZOagmP7ABItCl1auYk9dvEHNLxnfAXFanNluzAyGRtXxJ uUrCMPyToJkvDlvLIQaoRZejlfPA+MeHk6XIbBUmsfhUdNMmCtI0sClgoubnHVxH+EK1 hwp2mKb6i5mAP6o0ArulQ7faBGyMmCr4osy/PErhakoOyN0fg/nD+CBszD1IdFpFP8WY Yh8/ujMWRdOf7K8BSZ6U2Ks4bfZsmFfv7TuC9g/RvdBUis88u4YnMH7BsfsSiBG5BMsl pmOQ== 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=yVf+JWjYguybUXE9lEApUWctyBk3p/p3XkYEug6LcaI=; fh=bKY+Bhfw36JPTn9QEhVaXZsOS6hvbjEcUm8fbUdXSxo=; b=GgcolZ2juyJJ08G4IU4As8hDj9oP5M+9p4L3tJ5biNeN8pzOiH99CwcFSk+ZrOwGNk /3uPe2XQekstr+1AJ0ZIX3y0uRXkFJkmQQ4940r0HbrN8GL0OkXHxINahdfMSaZNrI/9 TibXTDYEBjdSrExoHfgUvdCEOhoIpgJnHMIQXV9iaZrcMmTIMEQtT9wULkHDb5aDMW7z ELNnfZiBBvxacfk8tHDWrfDpBCOklrEJ32ktGwsx9CNZciHcPYFuVPdQfEqWniGnTr24 JsrO8NpuVzUOA/t+Z71WiZqnPEkX3dUr5HxAZOtMlyLXSmOCCst0vMXEciAfs4e+ROLP vADg==; darn=lists.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=1771414633; x=1772019433; darn=lists.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=yVf+JWjYguybUXE9lEApUWctyBk3p/p3XkYEug6LcaI=; b=TKF4mABqqZnXA4ipfKGAWSGeDTO1P7z6SMgdII2XdX706XV5SfQk0dWOx8Csckv7WN 54dTtJJ4kE9VvMx5Iv4EzAyQDoZvqOO/mF8Z/eX/dadFGDdrjcuKI6u2d7b6Gb1mVcdI Not3oKdIVLkRCYgB0aQMIzqx6dMCjaFF4HQtcCuVNjRyyzYrtjSsoKf4AfOFwiV8/c5r n8e08g++lafjxBBGnYvT3thgCd9yhOe0S5sRJsWKPbhucZ94MTM6UMPGDx+Ic49haIVO gBer/Irp6U9FVcdmzNnUJ+jfY6F+VnoJ670/h0duAvsbgKdhZP3VaM8suu6oVtHyrYB6 /Dxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771414633; x=1772019433; 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=yVf+JWjYguybUXE9lEApUWctyBk3p/p3XkYEug6LcaI=; b=JXFH6zdslUx3YqplhzM5DOEbNVjpObkNG9vKbFFClurDA24Jj+i5xEMz6d7uQbMVHS 1a2geo3cbpP0GVwwYdVZtDX62+KaP9vI5op6GSMRTZhYZXiNOChasr073TsQrscJhwP9 h1zCzoRHKZG740ITPBQiQRl8lTEI2FNykbWR5pRZY1qH06XDwyxoGAvoSF1yE5Hfh8EG GCA/IzOSyVlND9WHT2pc7R8xiEGAsv+iBJuwY/h77cw4G3lO59wl7jjM42Oy1UtRwAyw OA0+P1FW4kfOzk/KJb5qc0K/zW4CRYmddO6DW1wsMUKImA2e1f4F22L5K3EU/kglNyOF GJBw== X-Forwarded-Encrypted: i=1; AJvYcCWs/zniTWfVj1DqGvc2lUldFyfsNEOctXAwfiq+jEqQOdTz20YvZ6xdz8gJ0UZ5SX20nnjoy4I0B67E8OGM@lists.postgresql.org X-Gm-Message-State: AOJu0Ywp8d2IQfVAqnKDbvkbxsf6d6S8Im+rV06SxVL17fIjnYi6Fbfg CnOuJXn58U6f2BtHlmDQpncFPoHe6mzr2Mt75RIKs9QSHg2TpHrV50+SYgxg7AI8mq/X0ggE5YH CxYi87uIYEYRQwwNQQZ16u1SqxU8kBV2rSvgxnmDo X-Gm-Gg: AZuq6aKM6CTK3zza7rVRTrRDMQyAmqOOD4Bq3lPx1eIabZUSZHqQVoBzEby90nymAXY y9wKbwAPVvanS6J+707oWIsRWOLx9yac8otse++OXJSf9YUFCyJQiYBJK6aHkBYOh08tsgtIs7P DwPnomSgJ86WKZ/zyknvWLFpFWoUFjSjo9h4YgP8CJN5LLX8fUZmh/CFRZSr4MJgbnR73tl9cfO 6YCW3RtkB6l+GbotY/BuEXoOLvjw4b8UXK4GoHBXiDUUK742qgu3oevaws9ifrgIrS2/pSnZDSw R+MXLiLhNKBsnbWzkbhMg9K39ELufIEW/o2fptpd8SjeAoj8ZPO9kgxVzTssciF0dVY= X-Received: by 2002:a05:6512:3e29:b0:59e:631b:6cea with SMTP id 2adb3069b0e04-59f83b8b249mr567679e87.5.1771414632963; Wed, 18 Feb 2026 03:37:12 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jakub Wartak Date: Wed, 18 Feb 2026 12:37:01 +0100 X-Gm-Features: AaiRm50-n-mc6dgqkFyzT10EiVALX9YoZoIMZhjDsxyn3_X8SZHlfQhdRJCp6DI Message-ID: Subject: Re: Flush some statistics within running transactions To: Bertrand Drouvot Cc: Sami Imseih , Michael Paquier , Fujii Masao , pgsql-hackers@lists.postgresql.org, Zsolt Parragi 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 Wed, Feb 18, 2026 at 6:41=E2=80=AFAM Bertrand Drouvot wrote: > > Hi, > > On Tue, Feb 17, 2026 at 01:18:35PM -0600, Sami Imseih wrote: > > > > > > > I do not have any further comments on this patchset. > > > > > > Thanks for the review! > > > > I flipped this CF entry to Ready-for-committer > > Thanks! > > PFA a mandatory rebase (nothing that needs review) due to a92b809f9da1. Hi Bertrand! Thanks for working on this. I've took a quick look on this patchset: v8-0005: you start using pgstat_schedule_anytime_update() from really hot macros like pgstat_count_buffer_hit() / pgstat_count_buffer_read() or pgstat_count_heap_getnext(), e.g.: #define pgstat_count_buffer_hit(rel) do { if (pgstat_should_count_relation(rel)) + { (rel)->pgstat_info->counts.blocks_hit++; + pgstat_schedule_anytime_update(); + } } while (0) where #define pgstat_schedule_anytime_update() is do { if (IsUnderPostmaster && !get_timeout_active(ANYTIME_STATS_UPDATE_TIMEOUT)) enable_timeout_after(ANYTIME_STATS_UPDATE_TIMEOUT, pgstat_flush_interval); } while (0) however that function (get_timeout_active()) is not static inlined so I'm wondering wouldn't there some major performance impact? Those buffer macros seem to be pretty heavy hitters, e.g. quite often even per single buffer in PinBufferForBlock(): pgstat_count_buffer_read(rel); if (*foundPtr) pgstat_count_buffer_hit(rel); so it seems to be: - often unnecessary double work (and probably as this is a function call to get_timeout_active it won't be optimized by compiler?) - but the main question is: why do we need that often to recheck and re-ena= ble timers so often from such hot places? v8-0001: this patch modifies ProcessInterrupts() which checks for AnytimeStatsUpdateTimeoutPending and it may happen that it takes LWLocks (pgstat_report_anytime_stat()->pgstat_flush_pending_entries()->e.g. pgstat_*_flush_cb()-> pgstat_lock_entry() -> LWLock) (It's more a question than finding): isn't it too risky to take that LWLock from potentially random spots as the CHECK_FOR_INTERRUPTS() is literally everywhere (~318 places). Wouldn't it be safer to flush from a couple of desired places? -J.