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 1tTkNn-009bDd-OO for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jan 2025 16:18:44 +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 1tTkNn-003CTW-1M for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jan 2025 16:18:42 +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.94.2) (envelope-from ) id 1tTkNm-003CTF-Nm for pgsql-hackers@lists.postgresql.org; Fri, 03 Jan 2025 16:18:42 +0000 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tTkNk-001unl-1t for pgsql-hackers@lists.postgresql.org; Fri, 03 Jan 2025 16:18:41 +0000 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4363ae65100so128829965e9.0 for ; Fri, 03 Jan 2025 08:18:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735921119; x=1736525919; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=ODzi97O3J5Xn2SvdIWHZXKJ7V5bCCgdO00Dh26Ywic0=; b=EmYYZPcgqOupXW1bymYQOdi1bk6B585qRv6MrMaOLjUlsMssysut7J1YtXmVuDYe/8 MHUVSdEMNRL1GQxOqE9QLEytGpoVZhGbKKU4tcYbOXjKWzJupF1B31gCIKeZo1K9meGt N0ioROt1W652fF0bwNbPOH27UNmYGwbGesnWYE+VTMsGeXfrs5FRZcIoFS1waID46Q/1 5ACIw3nmoIvwXjlsATdgr/5qt7q6QFVAcFUl7O9r7PbHuLjeOToraIVqxHh3uqkkLpxE wD7fZemf2HvsYq+37Tr1CHDr6PLk+Ag/htKw+cDDDY516/fTgxcpCILjTRV4qjRdp595 PqGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735921119; x=1736525919; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ODzi97O3J5Xn2SvdIWHZXKJ7V5bCCgdO00Dh26Ywic0=; b=aJ9Plp3j+rDhp550M7TuqCWTPjsOy0WgjWHGGjG7icTsYTQIWIWndjg7VK9TQRwEUN Vu9ucU0z8Dp0cKQ5kDbptt4TRxN1Fp1cAxMwP+7L0pT6QP/asTbcARBImBUIH2EWtYqJ Js5RbytQrE0IX3ClOlf50uJlvP2zkgFFqRFc2hA8kXupQMlq2Ct2Sih76VLD54cnnwmL QG2igql30vOtRQUYtgxta2DgcC2lXGSmWAye4M2POBT/vSQ/Ta0FKs9ElVPsPU7WHQi8 aA5TtHZmSEb2swvvVJD7NrrXLN2stzGK8F2b1ECY3LwamOeV8RHhvseHGfjvnD80eLSx pQJg== X-Forwarded-Encrypted: i=1; AJvYcCXxdTZa8145XArEQ2X3LO4hfzhQo4PT7t1l9viahNoaLpmnohEo9VrjQZNJQtvBv4BONmxLl08xwZzQpwSJ@lists.postgresql.org X-Gm-Message-State: AOJu0YxkRzhBC/3gFoKHbWHwckCiIjtW/ZXtLUG9mygW9cClSCOgxi9G R7ZEanSwdlQX4qJq9KYGNjfisJlNJLgyeDQOz9A6Dnp+mzF67y/s X-Gm-Gg: ASbGncsv+6ryBmaOb+atsRJk6JisHdLElSZvMSB92zSVBkieqTqLG2UZVT2d9xzNgO7 v98aBv9NH7AwowyFA4YriUhHA/pRUoo0zxIPlI7MuQ0ANyOZZnZduP4d74UedxMC9suYFRMJjMR jerVaUsKHP800JjWbFAx3csxGMjXWpmeLQ/1zOnBblIBswlw4pxw59d4DOGYBcSgfonX7iuYZCu Nkr/LyHzhaPfpRM7sCgVJZV1r/2/wVhEDmxAFDeBqmKE44zRSEteKmaWXAuvgtATil0rsiDeJcI Pol+xc++9ySfoRObVmvfAwS8NWkTZXuHRiac3rjVL8xmUir2gykYkKOMceEF732ZCZS4LAhfIq7 dHhrDuUI= X-Google-Smtp-Source: AGHT+IFeHaCwYyc3bKR/qGlgkf2+5+CQu3Jax0VRpPDU+kgTQEJoXUx/nIlwn7O4/1h2l7OXpJocHA== X-Received: by 2002:a05:6000:18a9:b0:386:3835:9fff with SMTP id ffacd0b85a97d-38a22406d43mr44957073f8f.59.1735921119120; Fri, 03 Jan 2025 08:18:39 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-236-134-5.eu-west-3.compute.amazonaws.com. [15.236.134.5]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38a1c8add5asm40458905f8f.107.2025.01.03.08.18.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jan 2025 08:18:38 -0800 (PST) Date: Fri, 3 Jan 2025 16:18:37 +0000 From: Bertrand Drouvot To: Kirill Reshke Cc: Robert Haas , Michael Paquier , pgsql-hackers@lists.postgresql.org Subject: Re: relfilenode statistics Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Tue, Dec 03, 2024 at 10:31:15AM +0000, Bertrand Drouvot wrote: > Hi, > > On Fri, Nov 29, 2024 at 08:52:13PM +0500, Kirill Reshke wrote: > > On Fri, 29 Nov 2024 at 20:20, Bertrand Drouvot > > wrote: > > > On Fri, Nov 29, 2024 at 11:23:12AM +0500, Kirill Reshke wrote: > > > > If we don’t have the relation OID when writing buffers out, can we > > > > just store oid to buffertag mapping somewhere and use it? > > > > > > Do you mean add the relation OID into the BufferTag? While that could probably > > > be done from a technical point of view (with probably non negligible amount > > > of refactoring), I can see those cons: > > > > Not exactly, what i had in mind was a separate hashmap into shared > > memory, mapping buffertag<>oid. > > I see. > > > > 2. Probably lot of refactoring > > > 3. This new member would be there "only" for stats and reporting purpose as > > > it is not needed at all for buffer related operations > > > > To this design, your points 2&3 apply. > > That said, it might also help for DropRelationBuffers() where we need to scan > the entire buffer pool (there is an optimization in place though). We could > imagine buffertag as key and the value could be the relation OID and each entry > would have next/prev pointers linking to other BufferTags with same OID. > > That's probably much more refactoring (and more invasive) that the initial idea > in this thread but could lead to multiple pros though. I'm not very familar with > the "buffer" area of the code and would also need to study the performance impact > to maintain this new hash map. > > Do you and/or others have any thoughts/ideas about it? As mentioned by Andres in [1], relying on the relation OID would not work to "recover" the stats because we don't have access to the relation oid during crash recovery. So, I'm going to resume working on the "initial" idea (i.e having the stats keyed by relfilenode). [1]: https://www.postgresql.org/message-id/xvetwjsnkhx2gp6np225g2h64f4mfmg6oopkuaiivrpzd2futj%40pflk55su36ho Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com