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 1sRltG-0011No-Iy for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jul 2024 04:58:47 +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 1sRltE-00B8L2-98 for pgsql-hackers@arkaria.postgresql.org; Thu, 11 Jul 2024 04:58:44 +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 1sRltD-00B8Ku-3e for pgsql-hackers@lists.postgresql.org; Thu, 11 Jul 2024 04:58:43 +0000 Received: from fhigh5-smtp.messagingengine.com ([103.168.172.156]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sRlt9-001VCq-8x for pgsql-hackers@lists.postgresql.org; Thu, 11 Jul 2024 04:58:42 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id 748EA1142012; Thu, 11 Jul 2024 00:58:36 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 11 Jul 2024 00:58:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1720673916; x=1720760316; bh=xznKYjfFOr ciXwHnwRhxtbdVlH/E/cNJpSZU2i6q4m8=; b=zROZG2GJMneMNF53PV4HHHUmub MAzVur1wVxMSMsxi395wm5mxcqvoDzZZMFyv+yjX+EPHseT9VDoygUJC+Qv56j5j r1Zt6YB6B05iuJylFTxXLXBGVlVETxW0H1YgnEa2v60YbgSXCl9SHxTkAOe1WhcC bNcRIrX9co40TqzIJvNBrmFePUpIFtpa5l0e9r9QguSh2yrhZCAOinAo7j39UJgX tgd47mOODDmNECBkNKr9tgnwvQwKF0xextZ9dSOAs9JSWGqAPQHdavq03r8Vp0Ul AYsuN4CqBinpp1ErahR4vYexq6sMS5buq5CU1210nJyV/a7zz7QiKxBL5esw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1720673916; x=1720760316; bh=xznKYjfFOrciXwHnwRhxtbdVlH/E /cNJpSZU2i6q4m8=; b=E4hrl3bGoJThR0+YE3BaFCr7giur4OOwdD2pSx28VAK8 hOqGrK1jmwNaskhgTQHBgdL67PvjgIDogP+v/sWo008a1aG3SSVPtPcmoDzzD0b2 +gTOMLKyHM15E/YfKiduoo7tbOwohw3fSPGHCpg0/P4M+gWL3VZIdkMhezfHX4M4 CXbEGlzwopnWTa7H4w62C17FzF4IQ6Jx0Jz1Pj2wFSxz72ugEwfVebFtdgc9ovO1 KLnEIHTCPmz6xbAr1kH8PchwozrXIaRCNhmBIO7lLs8byWgAePkTjxZ1/Ruc8ob/ rYBDuvFqgHcXGm8pC2G654sUKGHCeunzHy8UQ8urQQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddrfeefgdeltdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecufghrlhcuvffnffculdejtddmnecujfgurhepfffhvf evuffkfhggtggujgesghdtreertddtvdenucfhrhhomhepofhitghhrggvlhcurfgrqhhu ihgvrhcuoehmihgthhgrvghlsehprghquhhivghrrdighiiiqeenucggtffrrghtthgvrh hnpeetleeifedufffhhfdtteelgeeggeffhfekueevteeigfduudevudetgfegiedvjeen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmihgthh grvghlsehprghquhhivghrrdighiii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 11 Jul 2024 00:58:33 -0400 (EDT) Date: Thu, 11 Jul 2024 13:58:19 +0900 From: Michael Paquier To: Bertrand Drouvot Cc: pgsql-hackers@lists.postgresql.org Subject: Re: relfilenode statistics Message-ID: References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="1sqRfz4FfrHuBo9Z" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --1sqRfz4FfrHuBo9Z Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Jul 10, 2024 at 01:38:06PM +0000, Bertrand Drouvot wrote: > On Wed, Jul 10, 2024 at 03:02:34PM +0900, Michael Paquier wrote: >> and I am troubled by the approach taken (mentioned down by you), but >> that's invasive compared to how pgstats wants to be transparent with >> its stats kinds. >>=20 >> + Oid objoid; /* object ID, either table or function >> or tablespace. */ >> + RelFileNumber relfile; /* relfilenumber for RelFileLocator. */ >> } PgStat_HashKey; >>=20 >> This adds a relfilenode component to the central hash key used for the >> dshash of pgstats, which is something most stats types don't care >> about. >=20 > That's right but that's an existing behavior without the patch as: >=20 > PGSTAT_KIND_DATABASE does not care care about the objoid > PGSTAT_KIND_REPLSLOT does not care care about the dboid > PGSTAT_KIND_SUBSCRIPTION does not care care about the dboid >=20 > That's 3 kinds out of the 5 non fixed stats kind. I'd like to think that this is just going to increase across time. >> That looks like the incorrect thing to do to me, particularly >> seeing a couple of lines down that a stats kind is assigned so the >> HashKey uniqueness is ensured by the KindInfo: >> + [PGSTAT_KIND_RELFILENODE] =3D { >> + .name =3D "relfilenode", >=20 > You mean, just rely on kind, dboid and relfile to ensure uniqueness? Or table OID for the objid, with a hardcoded number of past relfilenodes stats stored, to limit bloating the dshash with too much past stats. See below. > So, I think it makes sense to link the hashkey to all the RelFileLocator > fields, means: >=20 > dboid (linked to RelFileLocator's dbOid) > objoid (linked to RelFileLocator's spcOid) > relfile (linked to RelFileLocator's relNumber) Hmm. How about using the table OID as objoid, but store in the stats of the new KindInfo an array of entries with the relfilenodes (current and past, perhaps with more data than the relfilenode to ensure the uniqueness tracking) and each of its stats? The number of past relfilenodes would be fixed, meaning that there would be a strict control with the retention of the past stats. When a table is dropped, removing its relfilenode stats would be as cheap as when its PGSTAT_KIND_RELATION is dropped. > Yeah, I also thought about keeping a list of "previous" relfilenodes stat= s for a > relation but that would lead to: >=20 > 1. Keep previous relfilnode stats=20 > 2. A more complicated way to look at relation stats (as you said) > 3. Extra memory usage >=20 > I think the only reason "previous" relfilenode stats are needed is to pro= vide > accurate stats for the relation. Outside of this need, I don't think we w= ould > want to retrieve "individual" previous relfilenode stats in the past. >=20 > That's why the POC patch "simply" copies the stats to the relation during= a > rewrite (before getting rid of the "previous" relfilenode stats). Hmm. Okay. -- Michael --1sqRfz4FfrHuBo9Z Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmaPZmsACgkQnvQgOdby QH3ZrA//bz5KcITcr5uq/tfIcPptLR3f1hnTWOoSZyCNRQq08FoWzclkESc2ucZS xOBvaHXrBDjRLYvTkXlibZQBs+Uj+qTERlH2GqzWXF+ZL+PVuyOaTMe5lGsxT+nA iszxJ1TtqXZ46us9Vszyr8CnM2GT8zxVwXzVuFxQin2YJEYhHlzdspe3OfAekt49 IHhgn9xC6/u9pWdOutnNlj93C4abAq9oN4hcum/loYM2aPzBSrCkxjnQg68h1/72 9qP56i58Tf9I66/Z1dsSIxckjR8eZM8BXcMGjKPiJbP6UZhpDTscAfeXHsCcwCD2 wcLOQJVTlunZ6oBmfwFbx4RZZoPkgd3a9Z/r1/4FlMQKvBWgpSE1x71UiQMmLxdb prg2be0/7S4zZjO/+6nzCRtXFTh+9d6kCzSPzcby6xLhu2ceMaJM2Vx5K4siVbNb iiNeR6zpbDi3jVIUlVmXFxZHj5WJbZ8gshYh1mqVn5kY8aVevoDS0Xm75dSFVt0X 5NCoxPmDJbv0i+R5PMaM8h0eg59Lds7UI3oI8CpIj32hTfZ6CFj1FsGWVx9FPbyY KAeSm/mTYF91ar+I+VFJo4rJV+VW1sjH1zgEhcpcH04K7xsnXUkNRDeg6QPrCUSC 0Hggy+uG92pQmZR5+r89ed+kzhxwJE4fZfx4MoCjdxeli4z9vaM= =Yxvg -----END PGP SIGNATURE----- --1sqRfz4FfrHuBo9Z--