Re: Should use MERGE use BulkInsertState ?

From: Justin Pryzby <pryzby(at)telsasoft(dot)com>
To: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, Amit Langote <amitlangote09(at)gmail(dot)com>, Japin Li <japinli(at)hotmail(dot)com>, Zhihong Yu <zyu(at)yugabyte(dot)com>, Simon Riggs <simon(dot)riggs(at)enterprisedb(dot)com>, pgsql-hackers(at)lists(dot)postgresql(dot)org, Tomas Vondra <tomas(dot)vondra(at)enterprisedb(dot)com>, Daniel Westermann <dwe(at)dbi-services(dot)com>, Erik Rijkers <er(at)xs4all(dot)nl>, Jaime Casanova <jcasanov(at)systemguards(dot)com(dot)ec>, Andres Freund <andres(at)anarazel(dot)de>
Subject: Re: Should use MERGE use BulkInsertState ?
Date: 2022-05-11 16:48:25
Message-ID: 20220511164825.GM19626@telsasoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, May 11, 2022 at 05:23:27PM +0200, Alvaro Herrera wrote:
> As I understand it, the point of using a ring is to throttle performance
> for bulk operations such as vacuum. I'm not sure why we would want to
> throttle either MERGE or INSERT; it seems to me that we should want them
> to go as fast as possible.

The point of the ring/strategy buffer is to avoid a seq scan/vacuum/COPY
clobbering the entire buffer cache when processing a table larger than
shared_buffers.

It also makes backends doing bulk operations responsible for their own writes,
rather than leaving other backends to clean up all their dirty buffers.

> If MERGE were to use a ring buffer, why wouldn't UPDATE do the same?
> There are some comments to that effect in src/backend/buffer/README --
> they do mention UPDATE/DELETE and not INSERT. It seems to me that these
> three commands (MERGE/UPDATE/DELETE) should be handled in similar ways,
> so I don't think we need to consider lack of MERGE using a ring buffer
> an open item for pg15.

I tend to think that a bulk commad either should or, at least, should be *able*
to use a ring buffer. The README doesn't consider INSERTs, but that's the one
that we'd be most interested in. I guess you're right that MERGE ought to do
what the existing commands are doing.

--
Justin

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2022-05-11 19:36:59 It's about time to run pgindent, renumber_oids, etc
Previous Message Jeff Davis 2022-05-11 16:39:48 Re: Comments on Custom RMGRs