From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
Cc: | Bradley Kieser <brad(at)sms-speedway(dot)com>, PgSQL ADMIN <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: OT: using column in an interval |
Date: | 2006-03-24 23:41:58 |
Message-ID: | 12667.1143243718@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> writes:
> On Thu, 23 Mar 2006, Bradley Kieser wrote:
>> last_backup: timestamp
>> backup_unit: integer - Represents day, week, quarter, annual, etc. The
>> text is stored in backup_code (e.g. 'days', 'months')
>> backup_period: integer - Represents the skip factor.
> CAST( backup_period || ' ' || backup_code AS interval) should give you an
> interval. If the units were constant, I'd say that using integer *
> interval is a better idea, but I think you'd need a function that say took
> backup_unit and gave back an interval of 1 <unit> to make that work, but
> that would possibly be cleaner overall.
This really seems like a case of a poorly chosen representation. Why
not just have the backup interval as an interval column, ie
last_backup: timestamptz (not timestamp, btw)
backup_interval: interval, can be eg '3 days' or '1 month' or whatever.
Then you can do
WHERE last_backup + backup_interval <= current_timestamp
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Sriram Dandapani | 2006-03-25 00:29:32 | WAL file naming convention |
Previous Message | Peter Eisentraut | 2006-03-24 23:19:52 | Re: Continuous On-line Backups |