X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 45EFE11F6089 for ; Mon, 24 Apr 2006 17:05:18 -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 86226-01-3 for ; Mon, 24 Apr 2006 17:04:45 -0300 (ADT) X-Greylist: delayed 00:31:43.835445 by SQLgrey- Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 1585611F6B05 for ; Mon, 24 Apr 2006 16:32:54 -0300 (ADT) Received: from av2.karneval.cz (av2.karneval.cz [81.27.192.108]) by svr4.postgresql.org (Postfix) with ESMTP id 88B4F5B030D for ; Mon, 24 Apr 2006 19:01:07 +0000 (GMT) Received: from localhost (localhost [127.0.0.1]) by av2.karneval.cz (Postfix) with ESMTP id 6C8476DB3C; Mon, 24 Apr 2006 21:01:02 +0200 (CEST) Received: from av2.karneval.cz ([127.0.0.1]) by localhost (av2 [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32689-07; Mon, 24 Apr 2006 21:01:01 +0200 (CEST) Received: from mail.karneval.cz (mx1.karneval.cz [81.27.192.53]) by av2.karneval.cz (Postfix) with ESMTP id 8D4E772541; Mon, 24 Apr 2006 21:01:01 +0200 (CEST) Received: from [192.168.1.101] (ip-89-102-195-181.karneval.cz [89.102.195.181]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.karneval.cz (Postfix) with ESMTP id 6AE7B17C9D0; Mon, 24 Apr 2006 21:01:01 +0200 (CEST) Message-ID: <444D2066.6090200@karneval.cz> Date: Mon, 24 Apr 2006 21:00:54 +0200 From: Tomas Vondra User-Agent: Mail/News 1.5 (X11/20060131) MIME-Version: 1.0 To: Ahmad Fajar Cc: pgsql-performance@postgresql.org Subject: Re: serious problems with vacuuming databases References: <003101c65c6b$ad079850$7f00a8c0@kicommunication.com> In-Reply-To: <003101c65c6b$ad079850$7f00a8c0@kicommunication.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by karneval.cz X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200604/541 X-Sequence-Number: 18625 > Hi Tomas, > > Tomas wrote: > We've decided to remove unneeded 'old' data, which means removing about > 99.999% of rows from tables A, C and D (about 2 GB of data). At the > beginning, the B table (containing aggregated from A, C and D) was emptied > (dropped and created) and filled in with current data. Then, before the > deletion the data from tables A, C, D were backed up using another tables > (say A_old, C_old, D_old) filled in using > ..... > 1) drop, create and fill table B (aggregated data from A, C, D) > 2) copy 'old' data from A, C and D to A_old, C_old a D_old > 3) delete old data from A, C, D > 4) dump data from A_old, C_old and D_old > 5) truncate tables A, C, D > 6) vacuum full analyze tables A, C, D, A_old, C_old and D_old > ---- > > I think you do some difficult database maintainance. Why you do that, if you > just want to have some small piece of datas from your tables. Why don't you > try something like: > 1. create table A with no index (don't fill data to this table), > 2. create table A_week_year inherit table A, with index you want, and some > condition for insertion. (eg: table A1 you used for 1 week data of a year > and so on..) > 3. do this step for table B, C and D > 4. if you have relation, make the relation to inherit table (optional). > > I think you should read the postgresql help, for more information about > table inheritance. > > The impact is, you might have much table. But each table will only have > small piece of datas, example: just for one week. And you don't have to do a > difficult database maintainance like you have done. You just need to create > tables for every week of data, do vacuum/analyze and regular backup. > > > Best regards, > ahmad fajar, Thanks for your advice, but I've read the sections about inheritance and I don't see a way how to use that in my case, as I think the inheritance takes care about the structure, not about the data. But I've read a section about partitioning (using inheritance) too, and it seems useful. I'll try to solve the performance issues using this. Thanks for your advices Tomas