From: Andres Freund <andres@anarazel.de>
To: Ben Chobot <bench@silentmedia.com>
Cc: pgsql-bugs@postgresql.org
Subject: Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql
Date: Fri, 6 Oct 2017 21:31:30 -0700
Message-ID: <20171007043130.zronedebya6iwtum@alap3.anarazel.de> (raw)
In-Reply-To: <73FBA179-C68C-4540-9473-71E865408B15@silentmedia.com>
References: <73FBA179-C68C-4540-9473-71E865408B15@silentmedia.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
Hi,
On 2017-10-04 13:59:20 -0700, Ben Chobot wrote:
> postgres=# CREATE OR REPLACE FUNCTION logical_replication_slot_lsn_delta(slot text) RETURNS pg_lsn AS
> postgres-# $$
> postgres$# BEGIN
> postgres$# return location from pg_logical_slot_peek_changes(slot,null,1) limit 1;
> postgres$# END
> postgres$# $$ language plpgsql;
As the issue is fixed now, I just want to mention that looking at
logical decoding output via the SQL interface, especially when doing it
in very small increments as you're suggesting here, is way much more
expensive than continually streaming changes via the replication
protocol. In a lot of cases it'll be orders of magnitude more expensive.
So if you can change your usecase to use that, you'll benefit. It also
avoids having to change between peek/get, because you can just send back
messages specifying up to where you've processed changes safely.
Greetings,
Andres Freund
--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs
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-bugs@postgresql.org
Cc: andres@anarazel.de, bench@silentmedia.com
Subject: Re: pg_logical_slot_peek_changes crashes postgres when called from inside pl/pgsql
In-Reply-To: <20171007043130.zronedebya6iwtum@alap3.anarazel.de>
References: <73FBA179-C68C-4540-9473-71E865408B15@silentmedia.com> <20171007043130.zronedebya6iwtum@alap3.anarazel.de>
* 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