pg.ddx.io pgsql-performance@postgresql.org mailing list archive
help / color / mirror / Atom feed From: Tom Lane <tgl@sss.pgh.pa.us>
To: David Jarvis <thangalin@gmail.com>
Cc: Thom Brown <thombrown@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Optimize date query for large child tables: GiST or GIN?
Date: Thu, 20 May 2010 15:52:50 -0400
Message-ID: <7767.1274385170@sss.pgh.pa.us> (raw )
In-Reply-To: <AANLkTikl8wlHPJaArMWO9XWgG0vk9tununw3eUAYh1IC@mail.gmail.com >
References: <AANLkTimi_Jh4J6bLZ8lZ0cGQ0VVG7XPCKaFN9GRHd6mP@mail.gmail.com >
<AANLkTilud7Qc25XZDziBMfzRnn8XCaNCo2jKHtW2-vdF@mail.gmail.com >
<AANLkTinmnWi8B_OQn_kQlG6t9SxZzhFmHbuKfBHhX3Vv@mail.gmail.com >
<AANLkTinD2fOrHDGEXPmEid85FzKGMKCq7raTaBoAsBdV@mail.gmail.com >
<AANLkTikKoZrb2i8XQaq-HVQ2Wxi9WXeclD3JefLiLMmk@mail.gmail.com >
<AANLkTimZ9zIEebspkg8Iy8vhEeBhe-JLJeJiYPcW88sJ@mail.gmail.com >
<AANLkTinTEyf_9ooDHv12vfsIuLihB2VqJ6NZGD2DnyHf@mail.gmail.com >
<AANLkTimk7lRS8FHJOot3tF-c6Ds4jexCvWKEQNU1V0Xt@mail.gmail.com >
<7143.1274382139@sss.pgh.pa.us >
<AANLkTim7O3Aalp31WKwBuTufYXeUMQWkwy51nvRcI0QY@mail.gmail.com >
<AANLkTikl8wlHPJaArMWO9XWgG0vk9tununw3eUAYh1IC@mail.gmail.com >
David Jarvis <thangalin@gmail.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
view thread (44+ messages) latest in thread
Message-ID: <7767.1274385170@sss.pgh.pa.us>
Permalink: ../7767.1274385170@sss.pgh.pa.us/
Also on: postgresql.org/message-id/7767.1274385170@sss.pgh.pa.us
copy link · copy postgr.es
reply 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: tgl@sss.pgh.pa.us, thangalin@gmail.com, thombrown@gmail.com
Subject: Re: Optimize date query for large child tables: GiST or GIN?
In-Reply-To: <7767.1274385170@sss.pgh.pa.us>
* 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