X-Original-To: pgsql-performance-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 754A89FA5BA for ; Wed, 28 Jun 2006 12:41:52 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 87605-03 for ; Wed, 28 Jun 2006 12:41:47 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 128EF9F9DCC for ; Wed, 28 Jun 2006 12:41:46 -0300 (ADT) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id B84E33093C; Wed, 28 Jun 2006 17:41:45 +0200 (MET DST) From: Ron Mayer X-Newsgroups: pgsql.performance Subject: Re: Some performance numbers, with thoughts Date: Wed, 28 Jun 2006 08:41:41 -0700 Organization: Hub.Org Networking Services Lines: 27 Message-ID: <44A2A335.50601@cheapcomplexdevices.com> References: <44973CC6.20309@janestcapital.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: usenet@news.hub.org To: Brian Hurt User-Agent: Thunderbird 1.5.0.4 (Windows/20060516) In-Reply-To: <44973CC6.20309@janestcapital.com> To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200606/487 X-Sequence-Number: 19844 Combining the "insert" statements in a big concatenated string joined by semicolons - rather than sending each individually can drastically speed up your inserts; making them much closer to the speed of copy. For example, instead of sending them separately, it's much faster to send a single string like this "insert into tbl (c1,c2) values (v1,v2);insert into tbl (c1,c2) values (v3,v4);..." presumably due to the round-trip packets sending each insert takes. Brian Hurt wrote: > > Inserts, 1,000 per transaction ~5,400 inserts/second > Copy, 1,000 element blocks ~20,000 inserts/second > When I last measured it it was about a factor of 4 speedup (3 seconds vs 0.7 seconds) by concatenating the inserts with sample code shown her [1]. If the same ratio holds for your test case, these concatenated inserts would be almost the exact same speed as a copy. Ron M [1] http://archives.postgresql.org/pgsql-performance/2005-09/msg00327.php