Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 4D0B81337B84 for ; Thu, 21 Oct 2010 13:08:00 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 11964-07 for ; Thu, 21 Oct 2010 16:07:53 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from aoskar.kilobug.org (kilobug.org [62.212.118.231]) by mail.postgresql.org (Postfix) with ESMTP id 4CFAD1337B63 for ; Thu, 21 Oct 2010 13:07:51 -0300 (ADT) Received: from kilobug by aoskar.kilobug.org with local (Exim 4.72) (envelope-from ) id 1P8xgB-0007PV-G9; Thu, 21 Oct 2010 18:07:47 +0200 From: Gael Le Mignot To: Tom Lane Cc: Gael Le Mignot , pgsql-performance@postgresql.org Subject: Re: Periodically slow inserts Organization: Pilot Systems References: <23677.1287672948@sss.pgh.pa.us> Mail-Copies-To: nobody X-Revolutionnary-Date: 30 =?iso-8859-1?Q?Vend=E9miaire?= an 219 de la =?iso-8859-1?Q?R=E9volution?= X-PGP-Fingerprint: 1F2C 9804 7505 79DF 95E6 7323 B66B F67B 7103 C5DA Date: Thu, 21 Oct 2010 18:07:47 +0200 In-Reply-To: <23677.1287672948@sss.pgh.pa.us> (Tom Lane's message of "Thu, 21 Oct 2010 10:55:48 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit 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/351 X-Sequence-Number: 40769 Hello Tom! Thu, 21 Oct 2010 10:55:48 -0400, you wrote: > 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. Thanks for your feedback. It seems to be related, at least, if I increase the work_mem variable, the slowness because bigger (up to 1 minute for a work_mem of 8mb) but much less frequent (around 0.05% instead of 0.5% of the requests for 8mb instead of 1mb). So a big work_mem and a regular vacuum would do the tick, I think. Does auto_vacuum triggers the gin index vacuuming too, or does it require a manual vacuum ? Regards, -- Gaël Le Mignot - gael@pilotsystems.net Pilot Systems - 9, rue Desargues - 75011 Paris Tel : +33 1 44 53 05 55 - www.pilotsystems.net Gérez vos contacts et vos newsletters : www.cockpit-mailing.com