Re: Up to 50x degradation in dblink performance when receiving notice traffic 19 vs 18

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Merlin Moncure <mmoncure(at)gmail(dot)com>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Fujii Masao <masao(dot)fujii(at)gmail(dot)com>, vignesh C <vignesh21(at)gmail(dot)com>
Subject: Re: Up to 50x degradation in dblink performance when receiving notice traffic 19 vs 18
Date: 2026-09-22 20:31:41
Message-ID: 1201635.1790109101@sss.pgh.pa.us
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Merlin Moncure <mmoncure(at)gmail(dot)com> writes:
> Bisecting revealed the obvious culprit:
> 112faf1378ee: Log remote NOTICE, WARNING, and similar messages using
> ereport().

> The commit solves an obvious problem, and I do not think it should be
> reverted. This does raise a couple of questions, however:
> * Is it really true that ereport() is up to 20x slower than stderr?
> * Why does stderr have such wierd performance variations?

I did a simple performance test, measuring tight loops around

ereport(LOG,
errmsg_internal("%s", my_string));

and

fprintf(stderr, "%s\n", my_string);

For me, ereport is consistently about 3x slower than fprintf
when using bare log-to-a-file (logging_collector off), or about
2x slower when using the logging collector with default options.
That's more or less in line with what I'd expect. So there's
something odd going on in your setup; where is log output going
exactly?

> * Why does dblink even bother with NOTICE level messages at all? They are
> not produced at all to the receiving client, only to the hosting database
> log (which IMO is very non-intuitive).

I think the intent of 112faf137 was to get log message prefixes
attached to these messages without disturbing the pre-existing
behavior about what gets recorded where. Maybe there's room for
a discussion about changing that, but since postgres_fdw has been
acting like that for a long time it might be a hard sell.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vadim Ponomarev 2026-09-22 20:36:59 Re: Reduce SyncRepLock contention on the commit path
Previous Message Masahiko Sawada 2026-09-22 20:27:01 Re: Adding a range check on the sequence index from the publisher.