Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XlOHg-0006vL-Op for pgsql-performance@arkaria.postgresql.org; Mon, 03 Nov 2014 20:31:28 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XlOHg-0002DA-6m for pgsql-performance@arkaria.postgresql.org; Mon, 03 Nov 2014 20:31:28 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XlOHf-0002Az-61 for pgsql-performance@postgresql.org; Mon, 03 Nov 2014 20:31:27 +0000 Received: from relay5-d.mail.gandi.net ([2001:4b98:c:538::197]) by magus.postgresql.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.80) (envelope-from ) id 1XlOHb-00065W-5y for pgsql-performance@postgresql.org; Mon, 03 Nov 2014 20:31:25 +0000 Received: from mfilter36-d.gandi.net (mfilter36-d.gandi.net [217.70.178.167]) by relay5-d.mail.gandi.net (Postfix) with ESMTP id 2BBE241C060; Mon, 3 Nov 2014 21:31:20 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at mfilter36-d.gandi.net Received: from relay5-d.mail.gandi.net ([217.70.183.197]) by mfilter36-d.gandi.net (mfilter36-d.gandi.net [10.0.15.180]) (amavisd-new, port 10024) with ESMTP id K-R+7pIAqhBz; Mon, 3 Nov 2014 21:31:18 +0100 (CET) X-Originating-IP: 98.27.58.255 Received: from [192.168.10.146] (cpe-098-027-058-255.nc.res.rr.com [98.27.58.255]) (Authenticated sender: adsend@dunslane.net) by relay5-d.mail.gandi.net (Postfix) with ESMTPSA id 26F8041C05C; Mon, 3 Nov 2014 21:31:17 +0100 (CET) Message-ID: <5457E614.1030902@dunslane.net> Date: Mon, 03 Nov 2014 15:31:16 -0500 From: Andrew Dunstan User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Tom Lane CC: pgsql-perform Subject: Re: assignment vs SELECT INTO References: <5457DECE.3070302@dunslane.net> <25915.1415046245@sss.pgh.pa.us> In-Reply-To: <25915.1415046245@sss.pgh.pa.us> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-performance Precedence: bulk Sender: pgsql-performance-owner@postgresql.org On 11/03/2014 03:24 PM, Tom Lane wrote: > Andrew Dunstan 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