Re: More guidance on ctid

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Bernice Southey <bernice(dot)southey(at)gmail(dot)com>
Cc: pgsql-docs(at)lists(dot)postgresql(dot)org
Subject: Re: More guidance on ctid
Date: 2025-12-22 22:09:02
Message-ID: aUnBfsbUbObEcY42@momjian.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-docs

On Sat, Nov 29, 2025 at 10:45:45PM +0000, Bernice Southey wrote:
> Bruce Momjian <bruce(at)momjian(dot)us> wrote:
> This is why I think the docs should say something different to what
> they currently do. The UPDATE example is fine only because it's run
> repeatedly until there are no more rows to find.
>
> I learned the primary key self-join pattern for order by/limit in
> delete/update soon after I began with postgres. I'm pretty sure ctid
> would have confused me. So I think the doc examples with an id column
> will be very helpful, and safer.
>
> If users discover ctid on internet forums or LLMs and then check the
> docs, I think they should get some notice of the concurrency risk.
>
> Here's a patch with an attempt to do the above.

I was traveling so I apologize for the delayed reply.

Sorry, I didn't like your proposed patch because it removes the ctid
example, and I didn't write that example so I don't feel enabled to
remove it. What I did do was to explain why ctid was safe in this
use-case. I also strengthened the documentation that ctid is not valid
for row references.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EDB https://enterprisedb.com

Do not let urgent matters crowd out time for investment in the future.

Attachment Content-Type Size
ctid.diff text/x-diff 1.8 KB

In response to

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Bruce Momjian 2025-12-23 00:14:31 Re: Which parameters are only used on startup?
Previous Message Robert Treat 2025-12-19 22:19:15 Re: Streaming Replication vs Logical