Re: Document efficient self-joins / UPDATE LIMIT techniques.

From: "Joel Jacobson" <joel(at)compiler(dot)org>
To: "Corey Huinker" <corey(dot)huinker(at)gmail(dot)com>
Cc: "Laurenz Albe" <laurenz(dot)albe(at)cybertec(dot)at>, "vignesh C" <vignesh21(at)gmail(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, "Marko Tiikkaja" <marko(at)joh(dot)to>
Subject: Re: Document efficient self-joins / UPDATE LIMIT techniques.
Date: 2024-02-14 16:55:07
Message-ID: cfdbcbce-c71c-43b3-a7a1-dd3b875dc122@app.fastmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Feb 13, 2024, at 23:56, Corey Huinker wrote:
> This patch came out of a discussion at the last PgCon with the person
> who made the "fringe feature" quote, who seemed quite supportive of
> documenting the technique. The comment may have been in regards to
> actually implementing a LIMIT clause on UPDATE and DELETE, which isn't
> in the SQL standard and would be difficult to implement as the two
> statements have no concept of ordering. Documenting the workaround
> would alleviate some interest in implementing a nonstandard feature.

Thanks for sharing the background story.

> As for whether it's commonplace, when I was a consultant I had a number
> of customers that I had who bemoaned how large updates caused big
> replica lag, basically punishing access to records they did care about
> in order to properly archive or backfill records they don't care about.
> I used the technique a lot, putting the update/delete in a loop, and
> often running multiple copies of the same script at times when I/O
> contention was low, but if load levels rose it was trivial to just kill
> a few of the scripts until things calmed down.

I've also used the technique quite a lot, but only using the PK,
didn't know about the ctid trick, so many thanks for documenting it.

/Joel

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jelte Fennema-Nio 2024-02-14 17:20:44 Re: [EXTERNAL] Re: Add non-blocking version of PQcancel
Previous Message Peter Eisentraut 2024-02-14 16:52:32 Re: What about Perl autodie?