pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Laurenz Albe <laurenz.albe@cybertec.at>
To: pinker <pinker@onet.eu>
To: pgsql-general@postgresql.org
Subject: Re: pg_sleep() inside plpgsql block - pro & cons
Date: Wed, 03 Oct 2018 08:12:30 +0200
Message-ID: <53f641b1f03458e226fa08fc08090d9300942fa6.camel@cybertec.at> (raw)
In-Reply-To: <1538487870670-0.post@n3.nabble.com>
References: <1538475003972-0.post@n3.nabble.com>
	<CA+bJJbzEe9Gt3g98Nn9SXx4WMdcnU6LvOG049B8Bc3MpN1cxFQ@mail.gmail.com>
	<1538487870670-0.post@n3.nabble.com>

pinker wrote:
> Francisco Olarte wrote
> > I do some similar things, but I sleep outside of the
> > database, is there a reason this can not be done?
> > 
> > Francisco Olarte.
> 
> Yes, I do try to convince them to do it outside the db, that's the reason
> I'm looking for some support here :) I'm not sure those 2 reasons are enough
> to convince them, wanted to be prepared...

The main reason why longer sleeping in the database is harmful
is that it causes long database transactions.  Remember that a
function always runs inside a database transaction.

Long transactions have two very bad consequences:

- They hold locks for a long time, blocking concurrent transactions
  and increasing the likelihood of deadlocks (the word "deadlock"
  often works wonders when convincing people).

- They keep autovacuum from freeing dead tuples, which can lead to
  bloated tables and indexes if you have many concurrent data
  modifications.  This wastes storage space and slows down
  sequential scans.

Yours,
Laurenz Albe
-- 
Cybertec | https://www.cybertec-postgresql.com





view thread (5+ messages)

Message-ID: <53f641b1f03458e226fa08fc08090d9300942fa6.camel@cybertec.at>
Permalink:  ../53f641b1f03458e226fa08fc08090d9300942fa6.camel@cybertec.at/
Also on:    postgresql.org/message-id/53f641b1f03458e226fa08fc08090d9300942fa6.camel@cybertec.at

 · 

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: laurenz.albe@cybertec.at, pinker@onet.eu
  Subject: Re: pg_sleep() inside plpgsql block - pro & cons
  In-Reply-To: <53f641b1f03458e226fa08fc08090d9300942fa6.camel@cybertec.at>
  References: <1538475003972-0.post@n3.nabble.com> <CA+bJJbzEe9Gt3g98Nn9SXx4WMdcnU6LvOG049B8Bc3MpN1cxFQ@mail.gmail.com> <1538487870670-0.post@n3.nabble.com> <53f641b1f03458e226fa08fc08090d9300942fa6.camel@cybertec.at>

* 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