X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 64FE1543FD for ; Wed, 4 May 2005 23:23:44 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 58482-04 for ; Thu, 5 May 2005 02:23:34 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 5B96D53C9E for ; Wed, 4 May 2005 23:23:33 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j452MuEF016748; Wed, 4 May 2005 22:22:56 -0400 (EDT) To: Christopher Kings-Lynne Cc: David Roussel , Mischa Sandberg , pgsql-perform Subject: Re: COPY vs INSERT In-reply-to: <42797C1A.3090303@familyhealth.com.au> References: <21154.1115136741@sss.pgh.pa.us> <1115146397.4277c89dc37b4@webmail.telus.net> <1115246490.1709.233393619@webmail.messagingengine.com> <42797C1A.3090303@familyhealth.com.au> Comments: In-reply-to Christopher Kings-Lynne message dated "Thu, 05 May 2005 09:51:22 +0800" Date: Wed, 04 May 2005 22:22:56 -0400 Message-ID: <16747.1115259776@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200505/46 X-Sequence-Number: 12210 Christopher Kings-Lynne writes: >> So what's the difference between a COPY and a batch of INSERT >> statements. Also, surely, fsyncs only occur at the end of a >> transaction, no need to fsync before a commit has been issued, right? > With COPY, the data being inserted itself does not have to pass through > the postgresql parser. Also, there is a whole lot of one-time-per-statement overhead that can be amortized across many rows instead of only one. Stuff like opening the target table, looking up the per-column I/O conversion functions, identifying trigger functions if any, yadda yadda. It's not *that* expensive, but compared to an operation as small as inserting a single row, it's significant. regards, tom lane