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 1vxFgB-005CNk-1I for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Mar 2026 02:40:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vxFg9-0042Q2-2h for pgsql-hackers@arkaria.postgresql.org; Tue, 03 Mar 2026 02:40:10 +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.96) (envelope-from ) id 1vxFg9-0042Pu-1k for pgsql-hackers@lists.postgresql.org; Tue, 03 Mar 2026 02:40:10 +0000 Received: from mail-qv1-xf30.google.com ([2607:f8b0:4864:20::f30]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vxFg7-000000006x8-2qF6 for pgsql-hackers@lists.postgresql.org; Tue, 03 Mar 2026 02:40:09 +0000 Received: by mail-qv1-xf30.google.com with SMTP id 6a1803df08f44-899a5db525cso46346796d6.3 for ; Mon, 02 Mar 2026 18:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772505606; cv=none; d=google.com; s=arc-20240605; b=XldGzTk3AgX0i/V025vKYXuVzkSMhmpyvyJutRm6L3zynKNusNoe0hChS2Jemrvvsy lVaQ5erktsS5QVdTcmFYZ18UFvq9Rcayl2DGULFcrhe/LYwwQ0csS6LhEMdXpbSYxp0H kWNB9/W8JmEu38/s3bT3NmC2aBIXfwegAk3Q9WilaOntcEm7kzNqvayBWcAMuPfkINdD mVYADNnUcoNXPJZbArlGzAXYdC39Pr0SgjtQeFAiZ2xJJf2nicW7zTUSs6hTRxt0Mq8B A+wZOC7C3HRSfU5lhgSUyxdLvFSx0vXvPN1NPDPshI4bCcR67jz8TzyGvxLsdknjUz8G Sizw== 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=rGdYkH1CoiFy8RSP6RA/pdZNW/3HloK6cxgmDziUdeI=; fh=HG8XR3tNZ/Yn8aQd5/nQX1aivMzpGjJ7X0f1U7oX+/4=; b=VibmdVAF75HWIlbLkWEK+M+dJnEP97Cdfs45KXVsmHKIiQT3erO3uYCsc0+8ERHgDF PFpwGZPTLoSFtoge8vNIJJlB1lll0GQPB/p/SA+qR+hLSbuXR/D6g+UQJ7Zt4D+h8Vlc cis43EpbJbf9e9Lihpi9KVtbE5luKCWHSiy98lcK5L33H6rnBOLDNm+2D1b2cXtXrz0c yfpjZ4flk3QORV4Iy7mdWNAgJdycZz1u75Ug4xOr3kKu8f4NeuNLacjIZqQcjFpsW3xP j0QXlWRbiFqZqEL6YqS6eWgn/Zoir6UdUyIvCZq7gBST117DhQdbq0TqzZynBr2IBHxF V30g==; 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=fittl.com; s=google; t=1772505606; x=1773110406; 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=rGdYkH1CoiFy8RSP6RA/pdZNW/3HloK6cxgmDziUdeI=; b=EcERsQndD76wcd8R6eRSm9HE8TMEKCbB6udYMNyXrbtMR7mUuN4YHwnhnFmbQfGA0F 2CmCgVzxoGLvF3veBdIjHSIqQR8Y7soYlsTNhOo7cV5zmJ5h3II16WgfJuoFtfn1Je/Y wj8rondarVSLKW4yNtOJhZpOxMxmkxrLzwZBU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772505606; x=1773110406; 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=rGdYkH1CoiFy8RSP6RA/pdZNW/3HloK6cxgmDziUdeI=; b=xHgZs0FYzP9tEm+pCzPxELSUcMC5evmG7hjAHGi9ZoiMIyW8t2HLlZtp0wH71XO9+B M4GWvo5Sbc79k7DNg6XGRJosnd9ZNuxW/v873ZpLNp/w5/+XtCPoVowxrop2Or0h7TwU 0RaRJRRdHoxqWC+8fbLvpmTGnJhTLNNWYC4q3Zu7uMsDwQt7H+k5nueeW6dtKT3UD1nT NmMNow8d3CrfB1gm5jO3sWqRWnsjLUw8MdfvsjZsiHFpJznvCqomjmNr8LYJUNydMnqD 393amLYVu1qhEP1WuIz81dX6RTGtzk/tBwn/4DnU5pOCbE4LwfZWzWEzCgGJ/3kvatSl 9xhQ== X-Gm-Message-State: AOJu0YxBU1Rs4T0zHA3KeHqNkAqSsnJa7KtziumM3jTy7pyY3B6Rpvvg k1VJQgyraBwaNtXUflSMkKsqt+3yT41mGqbUee7Uii0cdyPtj48TSIwRenVCWWkqWXSislmLF3i 8zxc4aIrGGNDPYuP0IaI9L38KUwe6oCj8a+EpG24N X-Gm-Gg: ATEYQzyZ93wB4DFnp0r7wr4NIvIG3ggShbDwCfuMTWncwaKUiDDrM/wGMelrwku9PVx 7Gt2Vjbxb7XbR0ObYRCWYo9yxAL6xz0aOwOy9yq5ak2CPs6UrqXaYkXCP7Vu9qRwTidS7CqexH3 EXgO90/5WiRCOeujShQVbigWzYoWb4MkUEMduRdZCMxBbdfWQup6wm104kS3ECQ/Qrk6qgTHQj5 5J4L8L+a8Yjy+ykC8xRZcMw9RwgxyI/lng2Ak5mg/dVJc1rLVQxtiAVW7y1Iq2F7OKldl//Q6HB 6Wz+I+uBgp2q7vQ+FFaGBmB3AxUB3pxMRF0QNfwySSeuNaiC9uOsWrGG65VAliTqQ2IpqOU= X-Received: by 2002:ad4:5d68:0:b0:89a:9b1:a224 with SMTP id 6a1803df08f44-89a09b1a3f8mr13794456d6.34.1772505606056; Mon, 02 Mar 2026 18:40:06 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Lukas Fittl Date: Mon, 2 Mar 2026 18:39:30 -0800 X-Gm-Features: AaiRm524gZI8PU1OankTEb9XZqIzkKqwVDRVArVBkU4XvsG_c8gx42Wnf_T6syQ Message-ID: Subject: Re: pg_buffercache: Add per-relation summary stats To: Jakub Wartak Cc: PostgreSQL Hackers 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 Mon, Mar 2, 2026 at 2:16=E2=80=AFAM Jakub Wartak wrote: > Hi Lukas, I have glanced at the patch briefly and couldn't find any > issues - patch looks solid, however I'm not sure if e.g. launching whole > NBuffers scan let's say every 5mins doesn't cause latency spikes on the > system? I mean introducing such function seems to invite users to use > pg_buffercache and I'm wondering if such regular pattern doesn't cause > issues? (this is not FUD :), just more like a question based on Your's > obervation) Thanks for taking a look! I think its the definitely the kind of thing you'd want to have people opt-in to (we currently only do it when someone enables pg_buffercache on their own, and allow turning it off completely), but on systems that experience performance issues due to what's in cache (and have some CPU capacity to spare), it seems to be helpful more than harmful, I think. To be clear on the sample size, this is a subset of our user base where we have experience with this, probably across 50-100 installs, roughly speaking, of small to medium sized production systems (size as in shared_buffers). Also, FWIW, this isn't going not helpful if your cache contents change completely once a minute, but in practice I think its more the unexpected effects of e.g. large data loads or background processes that mess with the cache, where tracking this over time can help you find the root cause of slowness - we currently run this on a 10 minute schedule when enabled, and that seems to work in terms of understanding large swings in cache contents. I think even if you ran this once an hour it could be helpful, and with the patch would give you the data you're interested in ("whats in the cache") without causing a large temporary file to be created. > > Also have you quantified what was the breaking point of previous query? > (You wrote "larger database servers", but was that like 128GB+ shared_buf= fers? > and if so what would be the difference in terms of runtime there -- also > like ~7x?) We've currently set the default limit of where we measure this with our tool at 200GB, but that's mainly because the temporary file that gets written out with pg_buffercache today to do the grouping just becomes noticeably large. I'll work on sharing more numbers in the following days for larger servers, to show the benefit of the patch. Thanks, Lukas -- Lukas Fittl