Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 9E4BE9FB8AF for ; Tue, 6 Mar 2007 11:47:09 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 23767-09 for ; Tue, 6 Mar 2007 11:46:52 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from floppy.pyrenet.fr (news.pyrenet.fr [194.116.145.2]) by postgresql.org (Postfix) with ESMTP id 44D089FB427 for ; Tue, 6 Mar 2007 11:46:52 -0400 (AST) Received: by floppy.pyrenet.fr (Postfix, from userid 106) id C8A1A308E2; Tue, 6 Mar 2007 16:46:50 +0100 (MET) From: "hatman" X-Newsgroups: pgsql.performance Subject: Re: Insert performance Date: 6 Mar 2007 07:46:36 -0800 Organization: http://groups.google.com Lines: 87 Message-ID: <1173195995.037709.232750@n33g2000cwc.googlegroups.com> References: <1172596221.393824.41130@j27g2000cwj.googlegroups.com> <45ED1996.7050008@archonet.com> <1173167607.4917.8.camel@hatman> <45ED217D.30404@archonet.com> <1173172748.4917.23.camel@hatman> <45ED37D1.3000503@archonet.com> Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Complaints-To: groups-abuse@google.com Cc: "Richard Huxton" , "Andreas Kostyrka" In-Reply-To: <45ED37D1.3000503@archonet.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20060607 Debian/1.7.12-1.2,gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 proxy-1.heig-vd.ch:8080 (squid/2.5.STABLE4) Complaints-To: groups-abuse@google.com Injection-Info: n33g2000cwc.googlegroups.com; posting-host=193.134.216.146; posting-account=gnwH_QwAAAAQLNv14JlAW4Wgi-SQgnth To: pgsql-performance@postgresql.org X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL, BAYES_50 X-Spam-Level: X-Archive-Number: 200703/181 X-Sequence-Number: 23586 Hi Richard, > > >>> No, as said above transactions are made of 100000 inserts... > >> Hmm - I read that as just meaning "inserted 100000 rows". You might fi= nd > >> that smaller batches provide peak performance. > > > Ahh ok ;-) sorry for my bad english... (yeah, i have been testing > > several transaction size 10000, 20000 and 100000) > > Not your bad English, my poor reading :-) > > > > >>>> If so, you'll be limited by the speed of the disk the WAL is running= on. > > >>>> That means you have two main options: > >>>> 1. Have multiple connections inserting simultaneously. > >>> Yes, you're right. That what i have been testing and what provide the > >>> best performance ! I saw that postgresql frontend was using a lot of = CPU > >>> and not both of them (i'm using a pentium D, dual core). To the oppos= it, > >>> the postmaster process use not much resources. Using several client, > >>> both CPU are used and i saw an increase of performance (about 18000 > >>> inserts/sec). > > >>> So i think my bottle neck is more the CPU speed than the disk speed, > >>> what do you think ? > >> Well, I think it's fair to say it's not disk. Let's see - the original > >> figure was 8000 inserts/sec, which is 0.125ms per insert. That sounds > >> plausible to me for a round-trip to process a simple command - are you > >> running the client app on the same machine, or is it over the network? > > > I did both test. On the local machine (using UNIX sockets) i can reach > > 18000 insert/sec with 10 clients and prepared statements. The same test > > using clients on the remote machine provide me 13000 inserts/sec. > > OK, so we know what the overhead for network connections is. > > > Now, with multiple client (multi-threaded inserts) my both CPU are quite > > well used (both arround 90%) so i maybe think that disk speeds are now > > my bottleneck. What do you think ? or maybe i will need a better CPU ? > > >> Two other things to bear in mind: > >> 1. If you're running 8.2 you can have multiple sets of values in an IN= SERT > >>http://www.postgresql.org/docs/8.2/static/sql-insert.html > > > Yeah, i'm running the 8.2.3 version ! i didn't know about multiple > > inserts sets ! Thanks for the tip ;-) > > Ah-ha! Give it a go, it's designed for this sort of situation. Not sure > it'll manage thousands of value clauses, but working up from 10 perhaps. > I've not tested it for performance, so I'd be interesting in knowing how > it compares to your other results. Yeah, as soon as possible i will give it a try ! Thanks for the feedback ;-) > > >> 2. You can do a COPY from libpq - is it really not possible? > > > Not really but i have been testing it and inserts are flying (about > > 100000 inserts/sec) !! > > What's the problem with the COPY? Could you COPY into one table then > insert from that to your target table? The main problem comes from our "real time" needs. We are getting information as a data flow from several application and we need to store them in the DB without buffering them too much... I have been testing the COPY using several statement (i mean using copy to add only a few rows to a specific table and then using it on an other table to add a few rows, etc...) and the perf are as bad as an insert ! COPY seems to be designed to add many many rows to the same table and not a few rows to several tables... So that's my main problem. Regards, Jo=EBl