| From: | Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com> |
|---|---|
| To: | Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)postgresql(dot)org |
| Subject: | Re: tid_blockno() and tid_offset() accessor functions |
| Date: | 2026-03-11 21:48:08 |
| Message-ID: | CAD21AoBdgM+4X=Wg0T==C9ahenm2nUb=q5AxxeEb_JVoKOzbgw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Fri, Feb 27, 2026 at 10:59 AM Ayush Tiwari
<ayushtiwari(dot)slg01(at)gmail(dot)com> 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.
Regards,
--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andres Freund | 2026-03-11 21:50:32 | Re: tid_blockno() and tid_offset() accessor functions |
| Previous Message | Jeff Davis | 2026-03-11 21:43:11 | Re: Change initdb default to the builtin collation provider |