pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
Date: Wed, 19 Oct 2022 09:44:26 -0500
Message-ID: <b4ed6642-8717-35b0-5067-3bebab131f66@gmail.com> (raw)
In-Reply-To: <1c4cb79ca48fa14246fbe78374da4ef9ac435a0a.camel@gmail.com>
References: <353091661.109766.1666124045054.ref@mail.yahoo.com>
	<353091661.109766.1666124045054@mail.yahoo.com>
	<72BEC008-DC6C-4D80-80A6-E1634CFFA656@thebuild.com>
	<VOMN1IM86IU4.HNL8WUVWUAMM3@ravi-surface>
	<80B77102-84D3-4AD8-B138-1C0C3341855B@thebuild.com>
	<2b93e12697bb273c493b47e04c762b39a66910ab.camel@gmail.com>
	<A13DA688-E00A-4679-8368-21265C76D823@thebuild.com>
	<1c4cb79ca48fa14246fbe78374da4ef9ac435a0a.camel@gmail.com>

On 10/19/22 08:06, Mladen Gogala wrote:
[snip]
>
>>
>> Applications do this kind of thing all the time, very successfully; it 
>> was just that the loop was in the application rather than in the procedure.
>>
>> High commit rates happen all the time, and they don't break PostgreSQL.  
>> For example, an IoT application collecting sensor data and doing many 
>> inserts per second is also doing many commits per second, since each bare 
>> INSERT is in its own transaction.  PostgreSQL handles it just fine.
>
> Point of my post is that the business logic, in your case it's IoT 
> sensors, determines what is transaction and when to commit. Advice like 
> "commit often and commit early", to paraphrase the famous Chicago mayor, 
> is easy to find but I would take it with grain of salt.

In the normal course of operation (i.e, not when bulk loading), you /should/ 
commit at the end of every "business transaction". We've committed after X 
business  when running stovepipe "batch" jobs processing input files.  In 
those cases, though, we had to track progress through the file; in the case 
of a rollback, the application had to go back to the last input file "save 
point" and start over.

-- 
Angular momentum makes the world go 'round.

view thread (16+ messages)  latest in thread

Message-ID: <b4ed6642-8717-35b0-5067-3bebab131f66@gmail.com>
Permalink:  ../b4ed6642-8717-35b0-5067-3bebab131f66@gmail.com/
Also on:    postgresql.org/message-id/b4ed6642-8717-35b0-5067-3bebab131f66@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: ronljohnsonjr@gmail.com
  Subject: Re: COMMIT IN STORED PROCEDURE WHILE IN A LOOP
  In-Reply-To: <b4ed6642-8717-35b0-5067-3bebab131f66@gmail.com>
  References: <353091661.109766.1666124045054.ref@mail.yahoo.com> <353091661.109766.1666124045054@mail.yahoo.com> <72BEC008-DC6C-4D80-80A6-E1634CFFA656@thebuild.com> <VOMN1IM86IU4.HNL8WUVWUAMM3@ravi-surface> <80B77102-84D3-4AD8-B138-1C0C3341855B@thebuild.com> <2b93e12697bb273c493b47e04c762b39a66910ab.camel@gmail.com> <A13DA688-E00A-4679-8368-21265C76D823@thebuild.com> <1c4cb79ca48fa14246fbe78374da4ef9ac435a0a.camel@gmail.com> <b4ed6642-8717-35b0-5067-3bebab131f66@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox