Re: Fastest way / best practice to calculate "next birthdays" - Mailing list pgsql-performance

From Jim Nasby
Subject Re: Fastest way / best practice to calculate "next birthdays"
Date
Msg-id 555F9E47.5020003@BlueTreble.com
Whole thread Raw
In response to Re: Fastest way / best practice to calculate "next birthdays"  (Bosco Rama <postgres@boscorama.com>)
List pgsql-performance
On 5/21/15 11:15 AM, Bosco Rama wrote:
> You could probably make some of that into a function that accepts a
> timestamptz and generates the two days.

You'll be better off if instead of 2 days it gives you a daterange:
http://www.postgresql.org/docs/9.4/static/rangetypes.html

I don't know about the exact ISO details, but your approach is the
correct one: find the date that the current week started on and then
build a range of [week start, week start + 7 days).

Also, note the use of [ vs ). That is the ONLY correct way to do this if
you're comparing to a timestamp.
--
Jim Nasby, Data Architect, Blue Treble Consulting
Data in Trouble? Get it in Treble! http://BlueTreble.com


pgsql-performance by date:

Previous
From: Jim Nasby
Date:
Subject: Re: How to clean/truncate / VACUUM FULL pg_largeobject without (much) downtime?
Next
From: Dave Johansen
Date:
Subject: MAX() and multi-column index on a partitioned table?