Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 054E19F964A for ; Sun, 23 Sep 2007 15:24:07 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 43273-03 for ; Sun, 23 Sep 2007 15:24:03 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from lists.commandprompt.com (host-254.commandprompt.net [207.173.203.254]) by postgresql.org (Postfix) with ESMTP id 020FB9F95AB for ; Sun, 23 Sep 2007 15:24:02 -0300 (ADT) Received: from perhan.alvh.no-ip.org ([190.95.8.15]) (authenticated bits=0) by lists.commandprompt.com (8.13.7/8.13.6) with ESMTP id l8NINqjx002563; Sun, 23 Sep 2007 11:23:53 -0700 Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id B242347C41; Sun, 23 Sep 2007 14:23:49 -0400 (CLT) Date: Sun, 23 Sep 2007 14:23:49 -0400 From: Alvaro Herrera To: Carlos Moreno Cc: pgsql-performance@postgresql.org Subject: Re: Possible explanations for catastrophic performace deterioration? Message-ID: <20070923182349.GC5679@alvh.no-ip.org> References: <46F6981B.1010600@mochima.com> <36e682920709230956p1312745eif1c6ba7a342dae3d@mail.gmail.com> <46F6AD2D.4090300@mochima.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <46F6AD2D.4090300@mochima.com> User-Agent: Mutt/1.5.16 (2007-06-11) X-Virus-Scanned: ClamAV version 0.91.1, clamav-milter version 0.91.1 on projects.commandprompt.com X-Virus-Status: Clean X-Greylist: Sender succeded SMTP AUTH authentication, not delayed by milter-greylist-1.6 (lists.commandprompt.com [192.168.2.159]); Sun, 23 Sep 2007 11:23:59 -0700 (PDT) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200709/403 X-Sequence-Number: 26948 Carlos Moreno wrote: >> , but my guess is that the total >> data size about enough to fit in shared_buffers or kernel cache. On >> the new system (or dropped/recreated database), it would've all or >> mostly fit in memory which would make things like count(*) work >> quickly. > > I don't understand this argument --- the newer system has actually > less memory than the old one; how could it fit there and not on the > old one? Plus, how could dropping-recreating the database on the same > machine change the fact that the entire dataset entirely fit or not in > memory?? Because on the older server it is bloated, while on the new one it is fresh thus no dead tuples. > The other part that puzzled me is that after running "select count(*) > ... " several times (that particular table is *very* small --- just > 200 thousand records of no more than 100 or 200 bytes each), then the > entire table *should* have been in memory ... Yet, it would still > take a few seconds (notice that there was a *considerable* > improvement from the first run of that query to the second one on the > old server --- from more than a minute, to just above two seconds.... > But still, on the new server, and after recreating the DB on the old > one, it runs in *no time* the first time). Bloat can explain this as well. >> My guess is that a vacuum full would've brought the other database >> back up to speed. > > I'm furious now that it didn't occur to me the vacuum full until > *after* I had recreated the database to see th problem disappear... > > I wonder if I should then periodically run a vacuum full --- say, once > a week? Once a month? Never. What you need to do is make sure your FSM settings (fsm_max_pages in particular) are high enough, and that you VACUUM (not full) frequently enough. -- Alvaro Herrera http://www.CommandPrompt.com/ The PostgreSQL Company - Command Prompt, Inc.