Search Postgresql Archives

Re: querying the age of a row

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxx

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 //


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux