From: Joshua D. Drake <jd@commandprompt.com>
To: Hannes Dorbath <light@theendofthetunnel.de>
Cc: pgsql-performance@postgresql.org
Subject: Re: Fastest way / best practice to calculate "next birthdays"
Date: Sun, 04 May 2008 09:11:34 -0700
Message-ID: <481DE036.90706@commandprompt.com> (raw)
In-Reply-To: <fvka82$1b10$1@news.hub.org>
References: <fvka82$1b10$1@news.hub.org>
Hannes Dorbath wrote:
> The subject basically says it all, I'm looking for the fastest
> (indexable) way to calculate the next birthdays relative to NOW() from a
> dataset of about 1 million users.
>
> I'm currently using a function based index, but leap year handling /
> mapping February 29 to February 28 gives me some headaches.
>
> Is there any best practice to do that in PostgreSQL?
postgres=# SELECT current_date|| ' a ' || to_char(current_date, 'Day'),
current_date + '1 Year'::interval || ' a ' || to_char(current_date + '1
Year'::interval, 'Day') as next_birthday;
?column? | next_birthday
------------------------+---------------------------------
2008-05-04 a Sunday | 2009-05-04 00:00:00 a Monday
?
Sincerely,
Joshua D. Drake
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: jd@commandprompt.com, light@theendofthetunnel.de
Subject: Re: Fastest way / best practice to calculate "next birthdays"
In-Reply-To: <481DE036.90706@commandprompt.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox