Re: assignment vs SELECT INTO

From: Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>
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:27:03
Message-ID: CAJghg4JpvKk4qG3SWZdH3zPk=3U-9Rc_BqYKD=JgLwp8F-LD6g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Mon, Nov 3, 2014 at 6:00 PM, Andrew Dunstan <andrew(at)dunslane(dot)net> wrote:

> 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 don't think so, because this take pretty much the same time:

SELECT ('a','b',i) INTO r;

Regards,
--
Matheus de Oliveira
Analista de Banco de Dados
Dextra Sistemas - MPS.Br nível F!
www.dextra.com.br/postgres

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Andrew Dunstan 2014-11-03 20:31:16 Re: assignment vs SELECT INTO
Previous Message Tom Lane 2014-11-03 20:24:05 Re: assignment vs SELECT INTO