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 1w0RRs-001uRG-2Q for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 21:50:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0RRr-00C5un-0Y for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 21:50:35 +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 1w0RRq-00C5ud-2q for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 21:50:35 +0000 Received: from fhigh-b1-smtp.messagingengine.com ([202.12.124.152]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1w0RRp-00000001ft9-2Wsw for pgsql-hackers@postgresql.org; Wed, 11 Mar 2026 21:50:34 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 4A1737A019B; Wed, 11 Mar 2026 17:50:33 -0400 (EDT) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Wed, 11 Mar 2026 17:50:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc:content-transfer-encoding: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=fm1; t=1773265833; x=1773352233; bh=Yel+FbeRslhbwCm+5bpdnPZ2Uw66qiw9TfrLuSba0F8=; b= bz0Kd2Pwp7kUVtWTcJHq/mK19+eKZZNbU3VhT2wPMyp49OkEZNFLWXh2tqejG4gL 0nsB3hyXMDgerLscRXX5sydjUGBfqvnqUc2JXY98BXHzO9Jh8WTuhjkzdjHTun96 nAAca7EBCKpFVbHmw5/ZNsTzaD6cDhD6EHKofw6tTmXf6frsD7X0FvvhR6dMRKOi DHAWqbW+yA8c6/g+2RAf2qdii6Ekai80KHWnPAKcvR/TedgRNK9sk7DesmTJSBiT TvAlY8xLGCoRXY8SsYuY3PDJC1x+0o89vlWtP03wLJeZTiYHkKNKkQ6JKTePSxCG Ht60TrP+ol7hOTbIKi0reg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :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-sender:x-me-sender:x-sasl-enc; s=fm1; t=1773265833; x= 1773352233; bh=Yel+FbeRslhbwCm+5bpdnPZ2Uw66qiw9TfrLuSba0F8=; b=A 3jmOHFqw7uvznYT4IZwnfGb8g3aT7snFlAiqZAJyou5F3liUlxsk8A3xhxbWni4u pe0F1bUhL8F92TYw5w6OGeT7J7Ee6S/Ina6/tRo2BGmWUjzMnKkBweZoC3jAof/b q3wxnGGKAS6L1cfkj1KqjqBaCfLLRKMXg0d4QYS+phQbT9Q+lZnGYTWkUZUL8UVI tPDlv8DSYeVe/SK5hOaW+ENQplVrpeGUQ/vYE+5y/YEt9qoOPr9PKnZ4WQYrcu/k XXAvQn4BKXTP+AWJjMn6AV23E4agivetUqMzhkmsTExhesYL52Nifw2s/F3+bMxL shBFOROdibG9l4EqeprQg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvkeehtddvucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkefstddttdejnecuhfhrohhmpeetnhgurhgv shcuhfhrvghunhguuceorghnughrvghssegrnhgrrhgriigvlhdruggvqeenucggtffrrg htthgvrhhnpedtleelvdfgjedvffeiueekfeeuleffhfegfffhgfffkeevueehieehhfei gffhvdenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grnhgurhgvshesrghnrghrrgiivghlrdguvgdpnhgspghrtghpthhtohepfedpmhhouggv pehsmhhtphhouhhtpdhrtghpthhtoheprgihuhhshhhtihifrghrihdrshhlghdtudesgh hmrghilhdrtghomhdprhgtphhtthhopehsrgifrggurgdrmhhshhhksehgmhgrihhlrdgt ohhmpdhrtghpthhtohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrd horhhg X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 11 Mar 2026 17:50:32 -0400 (EDT) Date: Wed, 11 Mar 2026 17:50:32 -0400 From: Andres Freund To: Masahiko Sawada Cc: Ayush Tiwari , pgsql-hackers@postgresql.org Subject: Re: tid_blockno() and tid_offset() accessor functions 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 2026-03-11 14:48:08 -0700, Masahiko Sawada wrote: > On Fri, Feb 27, 2026 at 10:59 AM Ayush Tiwari > wrote: > > > > Hi hackers, > > > > As of now we don't have any built-in way to extract the block and offset components from a TID. When people need to group by page (like for bloat analysis) or filter by specific blocks, they usually end up using the `ctid::text::point` hack: > > > > SELECT (ctid::text::point)[0]::bigint AS blockno, > > (ctid::text::point)[1]::int AS offset > > FROM my_table; > > > > This works, but it's pretty clunky, relies on the text representation, and isn't great if you're trying to parse TIDs outside of SQL. > > > > The attached patch adds two simple accessor functions: > > - `tid_blockno(tid) -> bigint` > > - `tid_offset(tid) -> integer` > > How about adding the subscripting support for tid data type? For > example, ctid[0] returns bigint and ctid[1] returns int. That just seems less readable and harder to find to me. I think it'd also make the amount of required code noticeably larger? Greetings, Andres