From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andrew Dunstan <andrew@dunslane.net>
Cc: pgsql-perform <pgsql-performance@postgresql.org>
Subject: Re: assignment vs SELECT INTO
Date: Mon, 03 Nov 2014 15:24:05 -0500
Message-ID: <25915.1415046245@sss.pgh.pa.us> (raw)
In-Reply-To: <5457DECE.3070302@dunslane.net>
References: <5457DECE.3070302@dunslane.net>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-performance>
Andrew Dunstan <andrew@dunslane.net> writes:
> andrew=# do $x$ declare r abc; begin for i in 1 .. 10000000 loop
> select 'a','b',i into r.x,r.y,r.z; end loop; end; $x$;
> DO
> Time: 63731.434 ms
> andrew=# do $x$ declare r abc; begin for i in 1 .. 10000000 loop r
> := ('a','b',i); end loop; end; $x$;
> DO
> Time: 18744.151 ms
> Is it simply because the SELECT is in effect three assignments, so it
> takes nearly 3 times as long?
I think it's more likely that the second example is treated as a "simple
expression" so it has less overhead than a SELECT.
regards, tom lane
--
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: tgl@sss.pgh.pa.us, andrew@dunslane.net
Subject: Re: assignment vs SELECT INTO
In-Reply-To: <25915.1415046245@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