Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 6DFFD9FB6D1 for ; Tue, 17 Jul 2007 17:17:32 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 04742-06 for ; Tue, 17 Jul 2007 17:17:21 -0300 (ADT) X-Greylist: delayed 00:23:37.140694 by SQLgrey-1.7.5 Received: from olive.qinip.net (olive.qinip.net [62.100.30.40]) by postgresql.org (Postfix) with ESMTP id 6BFED9FB6CB for ; Tue, 17 Jul 2007 17:17:25 -0300 (ADT) Received: from [10.0.0.21] (h8441139206.dsl.speedlinq.nl [84.41.139.206]) by olive.qinip.net (Postfix) with ESMTP id B8652185A5; Tue, 17 Jul 2007 21:53:47 +0200 (MEST) Message-ID: <469D1E4F.5090805@tweakers.net> Date: Tue, 17 Jul 2007 21:53:51 +0200 From: Arjen van der Meijden User-Agent: Thunderbird 2.0.0.4 (Windows/20070604) MIME-Version: 1.0 To: Thomas Finneid CC: pgsql-performance@postgresql.org Subject: Re: insert vs select into performance References: <469D1AD3.9030004@ifi.uio.no> In-Reply-To: <469D1AD3.9030004@ifi.uio.no> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/192 X-Sequence-Number: 25876 Have you also tried the COPY-statement? Afaik select into is similar to what happens in there. Best regards, Arjen On 17-7-2007 21:38 Thomas Finneid wrote: > Hi > > I was doing some testing on "insert" compared to "select into". I > inserted 100 000 rows (with 8 column values) into a table, which took 14 > seconds, compared to a select into, which took 0.8 seconds. > (fyi, the inserts where batched, autocommit was turned off and it all > happend on the local machine) > > Now I am wondering why the select into is that much faster? > Does the select into translate into a specially optimised function in c > that can cut corners which a insert can not do (e.g. lazy copying), or > is it some other reason? > > The reason I am asking is that select into shows that a number of rows > can be inserted into a table quite a lot faster than one would think was > possible with ordinary sql. If that is the case, it means that if I > write an pl-pgsql insert function in C instead of sql, then I can have > my db perform order of magnitude faster. > > Any comments? > > regards > > thomas > > ---------------------------(end of broadcast)--------------------------- > TIP 6: explain analyze is your friend >