Re: querying the age of a row - Mailing list pgsql-general

From Alban Hertroys
Subject Re: querying the age of a row
Date
Msg-id 46690F2E.9010004@magproductions.nl
Whole thread Raw
In response to Re: querying the age of a row  ("John D. Burger" <john@mitre.org>)
List pgsql-general
John D. Burger wrote:
> In any event, you say you need to know when a row is less than 24 hours
> old - that is presumably not an issue for these old rows.  I would add
> the column as suggested, but set it to some time in the past for the
> existing rows.  Or, you can set it to NULL, appropriately if you
> interpret NULL as unknown, and test the age with something like this:
>
>   where (age(coalesce(ts, '-infinity'::timestamp)) < '24 hours'::interval

...and actually you wouldn't even need the coalesce, as

  NULL < '24 hours'::interval IS NULL

...which is considered FALSE by the WHERE clause. It's probably wiser
not to rely on that in your code though, it can be confusing ;)

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
   7500 AK Enschede

// Integrate Your World //

pgsql-general by date:

Previous
From: Samatha Kottha
Date:
Subject: Re: setting login database
Next
From: "Alexander Staubo"
Date:
Subject: Re: cube problem