X-Original-To: pgsql-general@postgresql.org Received: from spampd.localdomain (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id F4205476331 for ; Sun, 4 May 2003 13:14:06 -0400 (EDT) Received: from beamish.nsd.ca (beamish.nsd.ca [205.150.156.194]) by postgresql.org (Postfix) with ESMTP id 2BFA2475F00 for ; Sun, 4 May 2003 13:14:06 -0400 (EDT) Received: (from smap@localhost) by beamish.nsd.ca (8.9.3/8.9.3) id NAA23332; Sun, 4 May 2003 13:13:03 -0400 X-Authentication-Warning: beamish.nsd.ca: smap set sender to using -f Received: from reddog.nsd.ca(192.168.101.30) by beamish.nsd.ca via smap (V2.1/2.1+anti-relay+anti-spam) id xma023330; Sun, 4 May 03 13:12:34 -0400 Received: from nsd.ca (jllachan-linux.nsd.ca [192.168.101.148]) by reddog.nsd.ca (8.8.7/8.8.7) with ESMTP id NAA21983; Sun, 4 May 2003 13:06:18 -0400 Message-ID: <3EB549F3.C7532C26@nsd.ca> Date: Sun, 04 May 2003 13:12:19 -0400 From: Jean-Luc Lachance X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.4.18-24.7.x i686) X-Accept-Language: en MIME-Version: 1.0 To: jim@nasby.net Cc: Kyle , Forum - PostGreSQL General Subject: Re: [SQL] Best way to delete time stamped data? References: <3EB2EBF0.8010003@ccidomain.com> <200305021619.41879.josh@agliodbs.com> <3EB510F1.8090708@ccidomain.com> <20030504113029.W66185@flake.decibel.org> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Status: No, hits=-30.7 required=5.0 tests=BAYES_01,EMAIL_ATTRIBUTION,QUOTED_EMAIL_TEXT,REFERENCES, REPLY_WITH_QUOTES,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) X-Archive-Number: 200305/83 X-Sequence-Number: 41738 The index can be used with a little rewrite (assuming trxdate is indexed): DELETE FROM ONLY richtable WHERE trxdate < current_timestamp - '90 days'::interval; "Jim C. Nasby" wrote: > > On Sun, May 04, 2003 at 09:09:05AM -0400, Kyle wrote: > > Josh, > > > > Thanks, even my boss can read the new statement: > > > > DELETE FROM ONLY richtable WHERE age(trxdate) > '90 days'; > > Just remember that that query won't use any index on trxdate, because > it has to calculate 'age(trxdate)' for every value in the table. > -- > Jim C. Nasby (aka Decibel!) jim@nasby.net > Member: Triangle Fraternity, Sports Car Club of America > Give your computer some brain candy! www.distributed.net Team #1828 > > Windows: "Where do you want to go today?" > Linux: "Where do you want to go tomorrow?" > FreeBSD: "Are you guys coming, or what?" > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faqs/FAQ.html