Re: More guidance on ctid

2025-11-24 Thread Bruce Momjian
On Sun, Nov 23, 2025 at 10:24:42AM +, Bernice Southey wrote:
> Hi,
> I'm wondering if the explanation of ctid in System Columns should have
> more guidance - especially as it's used in examples in the UPDATE and
> DELETE docs. So far I've been caught out by partitions and concurrent
> updates. This was after I changed primary keys to ctid, in self-joins
> that get ORDER BY or LIMIT, for UPDATE and DELETE.
> 
> I'm too unsure about this idea and my knowledge of ctid to propose a
> patch, but FWIW, here's my attempt:
> Ctid is useful for removing duplicate rows and efficient self-joins.
> Be aware that when ctid is used to find a row, only the first
> concurrent write will be applied. Also note that ctids are not unique
> across table partitions.
> 
> I'm learning my way through ctid, and the mailing lists, and am still
> in the foothills of both. Sorry about the topic-adjacent duplicates in
> other lists from my ramblings.

I didn't think we had ctid referenced in example queries, but I now see
it was added in PG 17:

commit 2daeba6a4e4
Author: Tom Lane 
Date:   Sun Apr 7 16:26:47 2024 -0400

Doc: show how to get the equivalent of LIMIT for UPDATE/DELETE.

Add examples showing use of a CTE and a self-join to perform
partial UPDATEs and DELETEs.

Corey Huinker, reviewed by Laurenz Albe

Discussion: 
https://postgr.es/m/CADkLM=caneqsuwpwnfi2jr4ix99e0ejm_3jtce-yjneqc7r...@mail.gmail.com

The examples use ctid to show how you can do incremental UPDATEs and
DELETEs, to avoid excessive cleanup/vacuum requirements.  While that
certainly is a good idea, it only works because the common table
expression examples, by definition, operate in the same snapshot.

I think the reporter above extrapolated this example to use ctid in
other, non-appropriate cases.  Should we add a warning to the docs to
explain that the general use of ctid is discouraged?

-- 
  Bruce Momjian  https://momjian.us
  EDB  https://enterprisedb.com

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




Re: Streaming Replication vs Logical

2025-11-24 Thread Robert Treat
On Wed, Feb 19, 2025 at 11:15 PM Robert Treat  wrote:
> On Wed, Feb 19, 2025 at 10:07 PM Bruce Momjian  wrote:
>> On Sat, Oct 12, 2024 at 07:01:31AM +0200, Laurenz Albe wrote:
>> > On Fri, 2024-10-11 at 15:53 -0700, Paul A Jungwirth wrote:
>> > > Our docs seem to contrast "streaming replication" to logical, but
>> > > these are not really opposites. Sometimes when they say "streaming"
>> > > they mean "physical".
>> > >
>> > > Probably this is historical: at first physical replication was the
>> > > only kind of streaming we had.
>> > >
>> > > Personally this has caused me a lot of confusion. For example,
>> > > recently when I read "Synchronous replication (see Section 26.2.8) is
>> > > only supported on replication slots used over the streaming
>> > > replication interface," I took it to mean synchronous replication only
>> > > worked for physical replication, not logical.
>> >
>> > What you are saying makes a lot of sense, and improving some of this
>> > is a good thing.
>> >
>> > Our current trminology is a mess.  There are some places in the 
>> > documentation
>> > that speak of physical vs. logical replication, while most places use the
>> > term "streaming replication" for physical replication.  I myself 
>> > consequently
>> > speak of "streaming replication" vs. "logical replication", even though 
>> > both
>> > stream data.  The protocol section of the documentation describes the
>> > "streaming replication protocol" and the "logical streaming replication 
>> > protocol".
>> >
>> > This is confusing, and I am also sometimes confused in the way you 
>> > described
>> > above.
>> >
>> > I think the mess is too well established to be really cleaned up.  But 
>> > adding
>> > some clarity is a good thing, so +1.
>>
>
> The attached patch expands on Paul's original patch, further consolidating 
> around the terms "streaming physical replication" and "streaming logical 
> replication" in places where it makes sense. I would note that there are 
> places where "streaming replication" makes sense (when it applies to both 
> types) and potentially when "physical replication" might make sense when we 
> could be talking about either streaming or wal shipping, so I don't think we 
> can completely eliminate that, but hopefully this improves what we have.
>
>>
>> I don't think our current setup is sustainable so I think it does need
>> to be cleaned up.  Also, physical/logical replication slots also needs
>> help, I think.
>>
>
> I took a look through some of the replication slot stuff and ISTM that it 
> basically gets the streaming logical/physical replication distinctions 
> correct, and I *think*
> it gets the slot distinctions correct as well, but to the degree there might 
> be some issue there, I think it could be addressed separately.
>

Hey Bruce,

Your recent commit on this topic [1] reminded me of the patch from
earlier this year meant to address some other areas where we are
blurry about using streaming vs physical vs logical replication. I
think (I might possibly still be jet lagged) I have updated the
previous version of that patch against HEAD, attached, and bumping it
up for review.

[1] 
https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=a5b69e30731fb623715ecf4c8073c0f2dee41678;hp=acbc9beaaed6ee88416e1dcef5df77fd5baba0be)


Robert Treat
https://xzilla.net


v3-0001-Clarify-usage-of-the-term-streaming-replication.patch
Description: Binary data


Re: Documentation improvement patch

2025-11-24 Thread Oleg

Daniel, Peter, thank you for the thorough review of the patch.

--
Oleg Sibiryakov

On 19.11.2025 17:14, Daniel Gustafsson wrote:

On 19 Nov 2025, at 12:02, Peter Eisentraut  wrote:
The following changes are left in your patch that should not be changed per the 
above discussion (all in doc/src/sgml/protocol.sgml):

I did consider these to be separate but re-reading I agree that they should be
removed.


Separately, maybe this could be improved further:

-Sets the maximum number of open files each server subprocess is
+Sets the maximum number of files each server subprocess is
 allowed to open simultaneously;  files already opened in the

I think it would be more correct to say something like "... number of files each 
server subprocess is allowed to have open simultaneously ..." (not how many open 
actions are happening concurrently).

I wonder if the original intent was to write "Sets the maximum number of open
files each server subprocess is allowed to have simultaneously;"?  That being
said, your suggestion is better so I'll go with that.

I will push the patch  with the above changes a bit later today.

--
Daniel Gustafsson