X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id E6FD0D1B4FE for ; Mon, 13 Oct 2003 19:54:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 25032-01 for ; Mon, 13 Oct 2003 16:54:00 -0300 (ADT) Received: from lorax.kcilink.com (lorax.kciLink.com [206.112.95.1]) by svr1.postgresql.org (Postfix) with ESMTP id 257F4D1B515 for ; Mon, 13 Oct 2003 16:54:01 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 034C93E60 for ; Mon, 13 Oct 2003 11:52:50 -0400 (EDT) Received: from lorax.kcilink.com ([127.0.0.1]) by localhost (lorax.kcilink.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 74350-05 for ; Mon, 13 Oct 2003 11:52:49 -0400 (EDT) Received: from lorax.kciLink.com (localhost [127.0.0.1]) by lorax.kcilink.com (Postfix) with ESMTP id 448543E45 for ; Mon, 13 Oct 2003 11:52:49 -0400 (EDT) Received: (from news@localhost) by lorax.kciLink.com (8.12.8p1/8.12.8/Submit) id h9DFqjUJ003727 for pgsql-performance@postgresql.org; Mon, 13 Oct 2003 11:52:45 -0400 (EDT) To: pgsql-performance@postgresql.org Path: not-for-mail From: Vivek Khera Newsgroups: ml.postgres.performance Subject: Re: Performance, vacuum and reclaiming space, fsm Date: Mon, 13 Oct 2003 11:52:44 -0400 Organization: Khera Communications, Inc., Rockville, MD Lines: 51 Message-ID: References: <3F8A6F82.6030300@persistent.co.in> <200310131937.14785.shridhar_daithankar@persistent.co.in> NNTP-Posting-Host: yertle.kcilink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: lorax.kcilink.com 1066060365 42314 216.194.193.105 (13 Oct 2003 15:52:45 GMT) X-Complaints-To: daemon@kciLink.com NNTP-Posting-Date: Mon, 13 Oct 2003 15:52:45 +0000 (UTC) User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Portable Code, berkeley-unix) Cancel-Lock: sha1:yTwS4qMnztVzr9+wyxa6DkgbeR8= X-Virus-Scanned: by amavisd-new at kciLink.com X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/432 X-Sequence-Number: 4180 >>>>> "SD" == Shridhar Daithankar writes: SD> If you have 150MB type of data as you said last time, you could SD> take a pg_dump of database, drop the database and recreate it. By SD> all chances it will take less time than compacting a database from SD> 2GB to 150MB. That's it? That's not so big of a disk footprint. SD> Drop the indexes and recreate them. While creating the index, all SD> the updates will be blocked anyways. Be *very careful* doing this, especially with UNIQUE indexes on a live system! My recommendation is to get a list of all indexes on your system with \di in psql, then running "reindex index XXXX" per index. Be sure to bump sort_mem beforehand. Here's a script I ran over the weekend (during early morning low-usage time) on my system: SET sort_mem = 131072; SELECT NOW(); SELECT relname,relpages FROM pg_class WHERE relname LIKE 'user_list%' ORDER BY relname; SELECT NOW(); REINDEX INDEX user_list_pkey ; SELECT NOW(); REINDEX INDEX user_list_XXX ; SELECT NOW(); REINDEX INDEX user_list_YYY ; SELECT NOW(); SELECT relname,relpages FROM pg_class WHERE relname LIKE 'user_list%' ORDER BY relname; The relpages used by the latter two indexes shrunk dramatically: user_list_XXX | 109655 user_list_YYY | 69837 to user_list_XXX | 57032 user_list_YYY | 30911 and disk usage went down quite a bit as well. Unfortunately, the pkey reindex failed due to a deadlock being detected, but the XXX index is most popular... This is my "hottest" table, so I reindex it about once a month. My other "hot" table takes 45 minutes per index to redo, so I try to avoid that until I *really* have to do it (about 6 months). I don't think you'll need a nightly reindex. Of course, regular vacuums throughout the day on the busy talbes help keep it from getting too fragmented. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Vivek Khera, Ph.D. Khera Communications, Inc. Internet: khera@kciLink.com Rockville, MD +1-240-453-8497 AIM: vivekkhera Y!: vivek_khera http://www.khera.org/~vivek/