Re: Optimize date query for large child tables: GiST or GIN?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: David Jarvis <thangalin(at)gmail(dot)com>
Cc: Thom Brown <thombrown(at)gmail(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Optimize date query for large child tables: GiST or GIN?
Date: 2010-05-20 19:52:50
Message-ID: 7767.1274385170@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

David Jarvis <thangalin(at)gmail(dot)com> writes:
> I was thinking that I could add three more columns to the measurement table:
> year_taken, month_taken, day_taken
> Then index those. That should allow me to avoid extracting years, months,
> and days from the *m.taken* date column.

You could, but I don't think there's any advantage to that versus
putting indexes on extract(day from taken) etc. The extra fields
eat more space in the table proper, and the functional index isn't
really any more expensive than a plain index. Not to mention that
you can have bugs with changing the date and forgetting to update
the derived columns, etc etc.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message David Jarvis 2010-05-20 19:58:16 Re: Optimize date query for large child tables: GiST or GIN?
Previous Message David Jarvis 2010-05-20 19:45:53 Re: Optimize date query for large child tables: GiST or GIN?