Re: generate_series() Interpretation

From: "David E(dot) Wheeler" <david(at)kineticode(dot)com>
To: Christopher Browne <cbbrowne(at)gmail(dot)com>
Cc: Steve Crawford <scrawford(at)pinpointresearch(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: generate_series() Interpretation
Date: 2011-06-27 20:19:05
Message-ID: 208A6FF0-6462-4624-86DD-E4D794D5BD33@kineticode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Jun 27, 2011, at 12:36 PM, Christopher Browne wrote:

> I wrote something on this on pgsql-general about 5 years ago that
> still seems pretty relevant.
>
> http://archives.postgresql.org/pgsql-general/2006-02/msg00159.php

iwantsandy.com (now defunct) originally had a solution like this. However it supported a slew of recurrences:

* hours
* 2xday
* days
* weeks
* months
* quarters
* years
* decades

We had materializations of all of these going out 5 years or so. It took up an incredible amount of database space and was really slow. I replaced it with a variation on the code described in this blog post:

http://www.justatheory.com/computers/databases/postgresql/recurring_events.html

The database was a fraction of the original size and, because views were usually limited to a month at most, the number of rows generated for a query to show recurring events was quite limited (no one had an hourly reminder that when for more than a couple of days). Queries were a lot faster, too.

So I think the materialization of dates can work in certain limited cases such as your "vacations 2005" example, and will be easier to use thanks to JOINs, I found that it performed poorly and was unnecessarily resource-intensive for our usage. And I suspect the same would be try for anyone building a calendar app with more than one simple kind of limited recurrence.

Best,

David

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Kohei KaiGai 2011-06-27 20:40:06 Re: [v9.2] DROP Reworks Part.0 - 'missing_ok' support of get_object_address
Previous Message Robert Haas 2011-06-27 19:57:09 Re: [v9.2] DROP Reworks Part.0 - 'missing_ok' support of get_object_address