Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 092B92E0054 for ; Wed, 4 Jun 2008 18:42:45 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 48117-02 for ; Wed, 4 Jun 2008 18:42:38 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from 30.mail-out.ovh.net (30.mail-out.ovh.net [213.186.62.213]) by developer.postgresql.org (Postfix) with SMTP id B94FB2E002F for ; Wed, 4 Jun 2008 18:42:41 -0300 (ADT) Received: (qmail 889 invoked by uid 503); 4 Jun 2008 21:43:00 -0000 Received: from unknown (HELO mail243.ha.ovh.net) (213.186.33.59) by 30.mail-out.ovh.net with SMTP; 4 Jun 2008 21:43:00 -0000 Received: from b0.ovh.net (HELO queue-out) (213.186.33.50) by b0.ovh.net with SMTP; 4 Jun 2008 21:42:31 -0000 Received: from par69-8-88-161-102-87.fbx.proxad.net (HELO apollo13.peufeu.com) (88.161.102.87) by ns0.ovh.net with SMTP; 4 Jun 2008 21:42:30 -0000 Date: Wed, 04 Jun 2008 23:50:09 +0200 To: "andrew klassen" , "James Mansion" Subject: Re: insert/update tps slow with indices on table > 1M rows From: PFC Cc: pgsql-performance@postgresql.org Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8 MIME-Version: 1.0 References: <354284.6724.qm@web37304.mail.mud.yahoo.com> Content-Transfer-Encoding: 8bit Message-ID: In-Reply-To: <354284.6724.qm@web37304.mail.mud.yahoo.com> User-Agent: Opera Mail/9.24 (Linux) X-Ovh-Tracer-Id: 884394378667558532 X-Ovh-Remote: 88.161.102.87 (par69-8-88-161-102-87.fbx.proxad.net) X-Ovh-Local: 213.186.33.20 (ns0.ovh.net) X-Spam-Check: DONE|H 0.5/N X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.632 tagged_above=0 required=5 tests=AWL=0.632 X-Spam-Level: X-Archive-Number: 200806/30 X-Sequence-Number: 30380 > I am using the c-library interface and for these particular transactions > I preload PREPARE statements. Then as I get requests, I issue a BEGIN, > followed by at most 300 EXECUTES and then a COMMIT. That is the > general scenario. What value beyond 300 should I try? > Thanks. Do you have PREPARE statements whose performance might change as the table grows ? I mean, some selects, etc... in that case if you start with an empty table, after inserting say 100K rows you might want to just disconnect, reconnect and analyze to trigger replanning of those statements. > Also, how might COPY (which involves file I/O) improve the > above scenario? It won't but if you see that COPY is very much faster than your INSERT based process it will give you a useful piece of information. I understand your problem is : - Create table with indexes - Insert batches of rows - After a while it gets slow Try : - Create table with indexes - COPY huge batch of rows - Compare time with above Since COPY also updates the indexes just like your inserts do it will tell you if it's the indexes which slow you down or something else. Also for insert heavy loads it's a good idea to put the xlog on a separate disk (to double your disk bandwidth) unless you have a monster disk setup. During your INSERTs, do you also make some SELECTs ? Do you have triggers on the table ? Foreign keys ? Anything ? How much RAM you have ? And can you measure the size of the table+indexes when it gets slow ? > > > ----- Original Message ---- > From: James Mansion > To: andrew klassen > Cc: pgsql-performance@postgresql.org > Sent: Wednesday, June 4, 2008 3:20:26 PM > Subject: Re: [PERFORM] insert/update tps slow with indices on table > 1M > rows > > andrew klassen wrote: >> I'll try adding more threads to update the table as you suggest. > You could try materially increasing the update batch size too.  As an > exercise you could > see what the performance of COPY is by backing out the data and > reloading it from > a suitable file. > > >