Re: [SQL] Best way to delete time stamped data?

From: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
To: jim(at)nasby(dot)net
Cc: Kyle <kyle(at)ccidomain(dot)com>, Forum - PostGreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: [SQL] Best way to delete time stamped data?
Date: 2003-05-04 17:12:19
Message-ID: 3EB549F3.C7532C26@nsd.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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(at)nasby(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Brian Hirt 2003-05-04 17:36:10 roman numerals
Previous Message Jim C. Nasby 2003-05-04 16:30:29 Re: [SQL] Best way to delete time stamped data?

Browse pgsql-sql by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2003-05-05 09:56:21 Re: Best way to delete time stamped data?
Previous Message Jim C. Nasby 2003-05-04 16:30:29 Re: [SQL] Best way to delete time stamped data?