[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pgsql-performance
Subject:    Re: [PERFORM] assignment vs SELECT INTO
From:       Andrew Dunstan <andrew () dunslane ! net>
Date:       2014-11-03 20:31:16
Message-ID: 5457E614.1030902 () dunslane ! net
[Download RAW message or body]


On 11/03/2014 03:24 PM, Tom Lane wrote:
> 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.
>
> 			


Well, I accidetally left out this case:

    andrew=# do $x$ declare r abc; begin for i in 1 .. 10000000 loop
    select row('a','b',i) into r; end loop; end; $x$;
    DO
    Time: 81919.721 ms


which is slower still.

cheers

andrew



-- 
Sent via pgsql-performance mailing list (pgsql-performance@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic