Re: More guidance on ctid - Mailing list pgsql-docs

From Bruce Momjian
Subject Re: More guidance on ctid
Date
Msg-id aUnBfsbUbObEcY42@momjian.us
Whole thread Raw
In response to Re: More guidance on ctid  (Bernice Southey <bernice.southey@gmail.com>)
Responses Re: More guidance on ctid
List pgsql-docs
On Sat, Nov 29, 2025 at 10:45:45PM +0000, Bernice Southey wrote:
> Bruce Momjian <bruce@momjian.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@momjian.us>        https://momjian.us
  EDB                                      https://enterprisedb.com

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

Attachment

pgsql-docs by date:

Previous
From: Robert Treat
Date:
Subject: Re: Streaming Replication vs Logical
Next
From: Bruce Momjian
Date:
Subject: Re: Which parameters are only used on startup?