Received: from maia.hub.org (unknown [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 5C4AF1337B4C for ; Thu, 21 Oct 2010 11:56:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 03495-07 for ; Thu, 21 Oct 2010 14:55:52 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id B6E3E133655C for ; Thu, 21 Oct 2010 11:55:51 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o9LEtmks023679; Thu, 21 Oct 2010 10:55:48 -0400 (EDT) To: Gael Le Mignot cc: pgsql-performance@postgresql.org Subject: Re: Periodically slow inserts In-reply-to: References: Comments: In-reply-to Gael Le Mignot message dated "Thu, 21 Oct 2010 14:25:44 +0200" Date: Thu, 21 Oct 2010 10:55:48 -0400 Message-ID: <23677.1287672948@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201010/344 X-Sequence-Number: 40762 Gael Le Mignot writes: > The problem is when we index objects into the full-text search part of > the database (which a DELETE and then an INSERT into a specific table), > the INSERT sometimes take a long time (from 10s to 20s), but the same > insert (and many other similar ones) are fast (below 0.2s). > This slowness comes regularly, about every 200 objects indexed, > regardless of the frequency of the inserts. Hm. You didn't say which PG version you're using, but if it's >= 8.4, I think this may be caused by GIN's habit of queuing index insertions until it's accumulated a reasonable-size batch: http://www.postgresql.org/docs/9.0/static/gin-implementation.html#GIN-FAST-UPDATE While you can turn that off, I think that doing so will reduce the index's search efficiency over time. It might be better to schedule regular vacuums on the table so that the work is done by vacuum rather than foreground queries. regards, tom lane