Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id A0EEB9FBE86 for ; Wed, 18 Jul 2007 16:12:08 -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 44622-05 for ; Wed, 18 Jul 2007 16:11:59 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from pat.uio.no (pat.uio.no [129.240.10.15]) by postgresql.org (Postfix) with ESMTP id 4964E9FBE50 for ; Wed, 18 Jul 2007 16:12:02 -0300 (ADT) Received: from mail-mx4.uio.no ([129.240.10.45]) by pat.uio.no with esmtp (Exim 4.67) (envelope-from ) id 1IBEwL-0000Lg-80 for pgsql-performance@postgresql.org; Wed, 18 Jul 2007 21:12:01 +0200 Received: from smtp.uio.no ([129.240.10.9] helo=mail-mx4.uio.no) by mail-mx4.uio.no with esmtp (Exim 4.67) (envelope-from ) id 1IBEwK-00034O-WC for pgsql-performance@postgresql.org; Wed, 18 Jul 2007 21:12:01 +0200 Received: from 113.80-203-240.nextgentel.com ([80.203.240.113] helo=[10.0.0.128]) by mail-mx4.uio.no with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1IBEwK-00034K-S7 for pgsql-performance@postgresql.org; Wed, 18 Jul 2007 21:12:00 +0200 Message-ID: <469E65D8.4030600@ifi.uio.no> Date: Wed, 18 Jul 2007 21:11:20 +0200 From: Thomas Finneid User-Agent: Thunderbird 1.5.0.12 (X11/20070604) MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: Re: insert vs select into performance References: <469D1AD3.9030004@ifi.uio.no> <0D6011B2-D09F-45E8-A5D7-5F84ADD1DC2B@seespotcode.net> <469D2B8E.7050208@ifi.uio.no> <3FCCED29-F5D9-4AEE-878E-A8F407B1FFEE@seespotcode.net> In-Reply-To: <3FCCED29-F5D9-4AEE-878E-A8F407B1FFEE@seespotcode.net> Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-UiO-SPF-Received: X-UiO-Resend: resent X-UiO-SPF-Received: X-UiO-Spam-info: not spam, SpamAssassin (score=0.0, required=12.0, autolearn=disabled, AWL=0.048) X-UiO-Scanned: 09FC041F8366B02B861D604C6DE3784A6D2464ED X-UiO-SPAM-Test: remote_host: 129.240.10.9 spam_score: 0 maxlevel 200 minaction 2 bait 0 mail/h: 91 total 2889824 max/h 8345 blacklist 0 greylist 0 ratelimit 0 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/227 X-Sequence-Number: 25911 Michael Glaesemann wrote: > > As they're individual inserts, I think what you're seeing is overhead > from calling this statement 100,000 times, not just on the server but > also the overhead through JDBC. For comparison, try > > CREATE TABLE ciu_data_type_copy LIKE ciu_data_type; > > INSERT INTO ciu_data_type_copy (id, loc_id, value3, value5, value8, > value9, value10, value11) > SELECT id, loc_id, value3, value5, value8, value9, value10, value11 > FROM ciu_data_type; > > I think this would be more comparable to what you're seeing. This is much faster than my previous solution, but, I also tested two other solutions - a stored function with array arguments and it performed 3 times better. - jdbc with COPY patch performed 8.4 times faster with text input, expect binary input to be even faster. regards thomas