Re: assignment vs SELECT INTO

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: pgsql-perform <pgsql-performance(at)postgresql(dot)org>
Subject: Re: assignment vs SELECT INTO
Date: 2014-11-03 20:24:05
Message-ID: 25915.1415046245@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Andrew Dunstan <andrew(at)dunslane(dot)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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Matheus de Oliveira 2014-11-03 20:27:03 Re: assignment vs SELECT INTO
Previous Message Andrew Dunstan 2014-11-03 20:00:14 assignment vs SELECT INTO