Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 3A3DB9FB1CE for ; Fri, 6 Oct 2006 13:53:55 -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 90328-02 for ; Fri, 6 Oct 2006 13:53:51 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from exchange.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by postgresql.org (Postfix) with ESMTP id BDF059FA4DD for ; Fri, 6 Oct 2006 13:53:50 -0300 (ADT) Received: from 10.10.1.37 ([10.10.1.37]) by exchange.g2switchworks.com ([10.10.1.2]) with Microsoft Exchange Server HTTP-DAV ; Fri, 6 Oct 2006 16:53:44 +0000 Received: from state.g2switchworks.com by mail.g2switchworks.com; 06 Oct 2006 11:53:43 -0500 Subject: Re: Performance Optimization for Dummies 2 - the SQL From: Scott Marlowe To: Carlo Stonebanks Cc: pgsql-performance@postgresql.org In-Reply-To: References: Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1160153623.6181.13.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Fri, 06 Oct 2006 11:53:43 -0500 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.078 tagged_above=0 required=5 tests=AWL, SPF_PASS, UNPARSEABLE_RELAY X-Spam-Level: X-Archive-Number: 200610/136 X-Sequence-Number: 21265 On Fri, 2006-10-06 at 11:44, Carlo Stonebanks wrote: > This didn't work right away, but DID work after running a VACUUM FULL. In > other words, i was still stuck with a sequential scan until after the > vacuum. > > I turned autovacuum off in order to help with the import, but was perfoming > an ANALYZE with every 500 rows imported. > > With autovacuum off for imports, how frequently should I VACUUM? Basically once the query planner stops using seq scans is usually good enough, although sometimes there's a bit of a period where it'll be using nested loops and then switch to merge etc... Every 500 is probably a bit much. After the first few thousand rows, run an analyze, and after about 5 to 10 thousand another analyze and you should be set.