Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1XlOAe-0006dL-Af for pgsql-performance@arkaria.postgresql.org; Mon, 03 Nov 2014 20:24:12 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1XlOAd-0005JJ-Nw for pgsql-performance@arkaria.postgresql.org; Mon, 03 Nov 2014 20:24:11 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XlOAc-0005JC-Jq for pgsql-performance@postgresql.org; Mon, 03 Nov 2014 20:24:10 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1XlOAZ-0006iq-IO for pgsql-performance@postgresql.org; Mon, 03 Nov 2014 20:24:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id sA3KO5cJ025916; Mon, 3 Nov 2014 15:24:05 -0500 From: Tom Lane To: Andrew Dunstan cc: pgsql-perform Subject: Re: assignment vs SELECT INTO In-reply-to: <5457DECE.3070302@dunslane.net> References: <5457DECE.3070302@dunslane.net> Comments: In-reply-to Andrew Dunstan message dated "Mon, 03 Nov 2014 15:00:14 -0500" Date: Mon, 03 Nov 2014 15:24:05 -0500 Message-ID: <25915.1415046245@sss.pgh.pa.us> X-Pg-Spam-Score: -2.5 (--) 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 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. 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