Received: from localhost (unknown [200.46.204.183]) by developer.postgresql.org (Postfix) with ESMTP id 5465A2E0088 for ; Tue, 22 Apr 2008 10:42:44 -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 58002-05 for ; Tue, 22 Apr 2008 10:42:35 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from secure.socket.ch (secure.socket.ch [212.103.70.36]) by developer.postgresql.org (Postfix) with ESMTP id D63652E0082 for ; Tue, 22 Apr 2008 10:42:35 -0300 (ADT) Received: from [194.153.94.2] (helo=[192.168.1.39]) by secure.socket.ch with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69 (FreeBSD)) (envelope-from ) id 1JoIlO-000J31-7V; Tue, 22 Apr 2008 15:42:33 +0200 Cc: pgsql-performance@postgresql.org Message-Id: <7A2BA520-ED19-418F-9339-95C7F7158664@socket.ch> From: Thomas Spreng To: Christopher Browne In-Reply-To: <87mynp3h3q.fsf@wolfe.cbbrowne.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Subject: Re: Oddly slow queries Date: Tue, 22 Apr 2008 15:42:25 +0200 References: <3D7728ED-3D36-47E6-9266-351073ED4E11@socket.ch> <60y77du7qs.fsf@dba2.int.libertyrms.com> <20B852C4-2ACA-445F-9289-558B6C86BAB4@socket.ch> <87mynp3h3q.fsf@wolfe.cbbrowne.com> X-Mailer: Apple Mail (2.919.2) X-SA-Exim-Connect-IP: 194.153.94.2 X-SA-Exim-Mail-From: spreng@socket.ch X-SA-Exim-Scanned: No (on secure.socket.ch); SAEximRunCond expanded to false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200804/316 X-Sequence-Number: 29809 On 19.04.2008, at 19:11, Christopher Browne wrote: > Martha Stewart called it a Good Thing when spreng@socket.ch (Thomas > Spreng) wrote: >> On 16.04.2008, at 17:42, Chris Browne wrote: >> What I meant is if there are no INSERT's or UPDATE's going on it >> shouldn't affect SELECT queries, or am I wrong? > > Yes, that's right. (Caveat: VACUUM would be a form of update, in this > context...) thanks for pointing that out, at the moment we don't run autovacuum but VACUUM ANALYZE VERBOSE twice a day. >>> 2. On the other hand, if you're on 8.1 or so, you may be able to >>> configure the Background Writer to incrementally flush checkpoint >>> data >>> earlier, and avoid the condition of 1. >>> >>> Mind you, you'd have to set BgWr to be pretty aggressive, based on >>> the >>> "10s periodicity" that you describe; that may not be a nice >>> configuration to have all the time :-(. >> >> I've just seen that the daily vacuum tasks didn't run, >> apparently. The DB has almost doubled it's size since some days >> ago. I guess I'll have to VACUUM FULL (dump/restore might be faster, >> though) and check if that helps anything. > > If you're locking out users, then it's probably a better idea to use > CLUSTER to reorganize the tables, as that simultaneously eliminates > empty space on tables *and indices.* > > In contrast, after running VACUUM FULL, you may discover you need to > reindex tables, because the reorganization of the *table* leads to > bloating of the indexes. I don't VACUUM FULL but thanks for the hint. > Pre-8.3 (I *think*), there's a transactional issue with CLUSTER where > it doesn't fully follow MVCC, so that "dead, but still accessible, to > certain transactions" tuples go away. That can cause surprises > (e.g. - queries missing data) if applications are accessing the > database concurrently with the CLUSTER. It's safe as long as the DBA > can take over the database and block out applications. And at some > point, the MVCC bug got fixed. I think I'll upgrade PostgreSQL to the latest 8.3 version in the next few days anyway, along with a memory upgrade (from 1.5GB to 4GB) and a new 2x RAID-1 (instead of RAID-5) disk configuration. I hope that this has already a noticeable impact on the performance. > Note that you should check the output of a VACUUM VERBOSE run, and/or > use the contrib function pgsstattuples() to check how sparse the > storage usage is. There may only be a few tables that are behaving > badly, and cleaning up a few tables will be a lot less intrusive than > cleaning up the whole database. That surely is the case because about 90% of all data is stored in one big table and most of the rows are deleted and newly INSERT'ed every night. cheers, tom