From: Tom Lane <tgl@sss.pgh.pa.us>
To: wolfgang@alle-noten.de
Cc: pgsql-general@lists.postgresql.org
Subject: Re: pg/tcl performance related
Date: Fri, 09 Mar 2018 11:43:00 -0500
Message-ID: <26361.1520613780@sss.pgh.pa.us> (raw)
In-Reply-To: <wolfgang-1180309095226.A0218096@noten19.local>
References: <wolfgang-1180309095226.A0218096@noten19.local>
wolfgang@alle-noten.de writes:
> Now, for pl/tcl, I could use either
> create function check(text) returns text as $$
> set data {
> # the data value
> }
> foreach d $data {
> # the work
> }
> $$ language pltcl;
> or
> create function check(text) returns text as $$
> if ![info exists GD(data)] {
> set GD(data) {
> # the data value
> }
> }
> foreach d $GD(data) {
> # the work
> }
> $$ language pltcl;
> Does this make any difference - i.e. how often will parsing the data happen?
Obviously, in the first case the "set data" will happen every time you
call the function. The cost of that should be about the same as it
would be in standalone Tcl. PL/Tcl builds a Tcl code object for the
function body on first call in a session, and thereafter reuses that
code object, so that you shouldn't have extra parsing overhead per
se ... but execution of the command costs something too.
regards, tom lane
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: tgl@sss.pgh.pa.us, wolfgang@alle-noten.de
Subject: Re: pg/tcl performance related
In-Reply-To: <26361.1520613780@sss.pgh.pa.us>
References: <wolfgang-1180309095226.A0218096@noten19.local> <26361.1520613780@sss.pgh.pa.us>
* 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