Re: elog vs errmsg_internal

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: elog vs errmsg_internal
Date: 2017-08-03 20:56:26
Message-ID: 16689.1501793786@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Peter Eisentraut <peter(dot)eisentraut(at)2ndquadrant(dot)com> writes:
> Is there a preferred method to select between using elog() and
> errmsg_internal()?

ereport(... errmsg_internal() ...) can be a win for debug messages that
are in hot code paths, because the test for whether the message will
get printed is able to short-circuit more work. In particular,
if you have moderately expensive functions like syscache lookups in
the argument list of elog(), I believe those functions get evaluated
even if we end up not printing anything. ereport() skips the
arg-list evaluation in such cases.

But if that doesn't seem very relevant, I'd tend to go for elog()
just because it's less typing.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2017-08-03 21:07:24 Re: xmltable SQL conformance
Previous Message Pavel Stehule 2017-08-03 20:54:29 Re: xmltable SQL conformance