X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id EEF08563DF for ; Mon, 28 Feb 2005 23:58:15 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 99937-05 for ; Mon, 28 Feb 2005 23:58:10 +0000 (GMT) Received: from smtp-gw-cl-c.dmv.com (smtp-gw-cl-c.dmv.com [216.240.97.41]) by svr1.postgresql.org (Postfix) with ESMTP id D501E565DD for ; Mon, 28 Feb 2005 23:58:08 +0000 (GMT) Received: from lanshark.dmv.com (lanshark.dmv.com [216.240.97.46]) by smtp-gw-cl-c.dmv.com (8.12.10/8.12.10) with ESMTP id j210EsEo087620 for ; Mon, 28 Feb 2005 19:14:54 -0500 (EST) (envelope-from sven@dmv.com) Subject: Inheritence versus delete from From: Sven Willenberger To: Postgresql Performance list Content-Type: text/plain Date: Mon, 28 Feb 2005 18:59:13 -0500 Message-Id: <1109635153.4620.44.camel@lanshark.dmv.com> Mime-Version: 1.0 X-Mailer: Evolution 2.0.4 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.39 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.329 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200502/376 X-Sequence-Number: 10705 Trying to determine the best overall approach for the following scenario: Each month our primary table accumulates some 30 million rows (which could very well hit 60+ million rows per month by year's end). Basically there will end up being a lot of historical data with little value beyond archival. The question arises then as the best approach of which I have enumerated three: 1) Just allow the records to accumulate and maintain constant vacuuming, etc allowing for the fact that most queries will only be from a recent subset of data and should be mostly cached. 2) Each month: SELECT * INTO 3monthsago_dynamically_named_table FROM bigtable WHERE targetdate < $3monthsago; DELETE FROM bigtable where targetdate < $3monthsago; VACUUM ANALYZE bigtable; pg_dump 3monthsago_dynamically_named_table for archiving; 3) Each month: CREATE newmonth_dynamically_named_table (like mastertable) INHERITS (mastertable); modify the copy.sql script to copy newmonth_dynamically_named_table; pg_dump 3monthsago_dynamically_named_table for archiving; drop table 3monthsago_dynamically_named_table; Any takes on which approach makes most sense from a performance and/or maintenance point of view and are there other options I may have missed? Sven Willenberger