Re: How to create a multi-column index with 2 dates using 'gist'?

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: How to create a multi-column index with 2 dates using 'gist'?
Date: 2009-08-25 11:57:50
Message-ID: 20090825115750.GO5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-performance

On Tue, Aug 25, 2009 at 07:39:26PM +0800, Fred Janon wrote:
> Basically I have an events table representing events with a duration
> (startdate, enddate). I was wondering if it would improve the performance if
> I was creating a separate table (indexed as you suggested) with the date
> ranges (startdate, enddate) and point to that from my events table. That
> would eliminate the duplicate ranges, costing a join to find the events
> within a date range, but maybe improving the search performance for events
> that overlap a certain date range. Any feedback on that?

It depends on the sorts of queries you're going to be doing most often.

Not sure how is best to explain when GiST is going to win, but if you
think of a rectangle with the start dates going along the top edge and
the end dates going down the side. If you sort the values by the start
date will you end up with most of them on a diagonal or will they be
scattered randomly around. I.e the less correlation between the start
and end date the better GiST will do, relative to a btree index. I
think that's right anyway!

--
Sam http://samason.me.uk/

In response to

Browse pgsql-general by date

  From Date Subject
Next Message chanda roopesh 2009-08-25 12:12:06 backup and recovery problem
Previous Message Fred Janon 2009-08-25 11:39:26 Re: How to create a multi-column index with 2 dates using 'gist'?

Browse pgsql-performance by date

  From Date Subject
Next Message Jaime Casanova 2009-08-25 20:16:40 Re: [PERFORMANCE] how to set wal_buffers
Previous Message Fred Janon 2009-08-25 11:39:26 Re: How to create a multi-column index with 2 dates using 'gist'?