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 1w0RQA-001uPz-2p for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 21:48:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w0RQ9-00C3Xp-0e for pgsql-hackers@arkaria.postgresql.org; Wed, 11 Mar 2026 21:48:49 +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 1w0RQ8-00C3Xg-2k for pgsql-hackers@lists.postgresql.org; Wed, 11 Mar 2026 21:48:49 +0000 Received: from mail-lf1-x133.google.com ([2a00:1450:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w0RQ7-00000001frL-1Hmf for pgsql-hackers@postgresql.org; Wed, 11 Mar 2026 21:48:48 +0000 Received: by mail-lf1-x133.google.com with SMTP id 2adb3069b0e04-5a12f6871b2so518217e87.1 for ; Wed, 11 Mar 2026 14:48:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773265725; cv=none; d=google.com; s=arc-20240605; b=dNwNnfbyclVbCjiTs1gjaaXCQuAxcgErQguS1Y9YRejv7fo7d7vbbCrYDykBwgNlWZ RQ9Oz855TqXCR+K+2EA5TfyHBgpo/m0Q2piN0RtmgcYCDT5gt0A5qhWvkoUqnAiFPe5H tGgyqKH/wMJjGKxTFNR4HG5vsvimC0KRgdXPDIJo2Q7SJ++YXedbyv8vGYYrIuWugwUU ss8O2Bg+fpzX41CFVGFnLrafdQAO1bSyJCB0NUIUO0SPNvX9OnBa2nftp7jjOqWBPWiA sR1lwbwF2Fp6QSMLBLxZyjTk+CyFBmJ2G+FQhgmYQPvKBo0W1th7GUmZRq5m3QR6JezD B9ew== 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=COGMlXZKenzVSunReZ9WjqH3xpouwZ+MT94Hfi+4Czw=; fh=qSJsZD8AMIawn1/Kh/UckT9T7ONulmOmBrtK2ismc4Y=; b=FUkX0TKjVZ7CwbL1uRziwGMnRFPK2JhEoUeGxUofnUQHj9TcC0GuQtHBwFwrvEgZs2 yLOjnD7q3DzGXR3PrChce/p3lhlkKOjEASxXFotXTJoL0Fb3VUVQQHQfa7IILbHB4QEO TXhvEkhZpTq/+rVBkVDxDTNwUkIvo4VL7XkCFtb49d4nFrMkBzQaJ+7LoQDwmDueB4Uh 2rQs5EjoKeDert9qrUs+AUIag58hZlT2Vb4OOab5jpszGxD74OTJrr0rZ6n6W145ugPI phdAijVSLQR61FEwvJJ6wUZCywTw5XBdplnnoxKrtpOvTgULtlkqenElanI0N6Yk2vBz bHMg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773265725; x=1773870525; darn=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=COGMlXZKenzVSunReZ9WjqH3xpouwZ+MT94Hfi+4Czw=; b=X1i0x8E/WhVrG2WVd7WEtSP1K6+KsOg3h5a1Z5Z/Sa1JIbzBxKJTIkyG+27yswLcWe ato2xrP5gUZ5wrCxwgpOYm6AR+VUcwsbQzwmQDonPDzaApRpNTNtY+CEyfUFQvrWViq6 CghjXOyWMCuRmMmL/8140VKf6ge0k+4GGf9CvPQKcHZMtoV9zPPjBJH4YYN0QBSgL+Ma uPGNYrfuU7ii080bkpvvz9olZ1tQYmfJiRtEYuyRboiblAqxCvYQ9Fiz1rIouScSwUHs Ms7lSb+XUkD5/14ofzVQuKKaVtuC6rQmxXCrhTzXkWapkVKgHMbxcjTTPzPdeiG+JLkH BzAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773265725; x=1773870525; 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=COGMlXZKenzVSunReZ9WjqH3xpouwZ+MT94Hfi+4Czw=; b=A5CUDMRNT2iIs5xxKGVddwRKMX/Jkbxv9S2+qVsETLXVpxJeZmuRh41SgQgxkyeLAG aEKvxjyDXaZpV6NHXmLzLtc3HZIU5jTPnltBeH12EHeKAfwwd8CWJ2TK5ZWVyMO/yyt4 wMTTcKuASk8xOP00lZDGzmOi0xkLuvFVFSuQ+Zv6QJtZyWZB7G4sliFmUwtVnEKrYYV7 EjGIna56q7bOCsAJ8VXU3ie0RDDpU7VSw+elXGIIjaEACbKY1Jk3Dua9FasMm9aC00ij nuzIRR1qeP8qHZFOk3VvHSCCgVoz543QhNldxw0Y+Y/52Cjdkf8WBmSFJAgXH+MuXfcF AJjw== X-Gm-Message-State: AOJu0YwdVtQNexZfXPWJEyrXl7UmLHZTo2Cbv4TPAS1SyhVZTzwFKqco mKAJKQ7Mg6loAVm10f7KSszfQxYWUxt3MX7mDjBpPDJmYZ8mOLc1o1PIVCEX/5JlMjCCBLJLwmI 5GaTqDz2kDyGAdNtr1Cvd9HOcfjvcZ88= X-Gm-Gg: ATEYQzytl8aoEVti5lYXM9Cspfyy5pPHsVndIUzOzjzLj0pDuU1JFFL8B7qK/YLFKdQ ZFQM0pJzKjvyB3QwJt4q6xqxcwW2TjqGSWWYSsYGlbag0MOYy7EI59EdKmqId4H+6yMBr+V+lPq Op8giFQSp5ikGkJ9bC5TZrhqvc3/TcQ2oH+jqyJ+VvqOiPFkvjiOEZSOSC/ulQlsFun+bxeCai2 XoezSlT/Ma5YveM9DinKkOWydkEI9Ar06jNJZVSa+raplq0v9dqnhWYk9o+K3BjLGvVXuje2Vpg trvyQkxb X-Received: by 2002:ac2:4a67:0:b0:5a1:450f:5e38 with SMTP id 2adb3069b0e04-5a156cc0585mr1125633e87.36.1773265725075; Wed, 11 Mar 2026 14:48:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Masahiko Sawada Date: Wed, 11 Mar 2026 14:48:08 -0700 X-Gm-Features: AaiRm503z0chQ67maUnR7EJc33gCr8e3RDiAUU-I0Z9PJfKrb7EAr-IK-eNk4hg Message-ID: Subject: Re: tid_blockno() and tid_offset() accessor functions To: Ayush Tiwari Cc: pgsql-hackers@postgresql.org 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 Fri, Feb 27, 2026 at 10:59=E2=80=AFAM 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 an= alysis) 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, an= d 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. Regards, --=20 Masahiko Sawada Amazon Web Services: https://aws.amazon.com