Re: Timestamp indicies not being used!

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Timestamp indicies not being used!
Date: 2009-07-19 12:48:19
Message-ID: 20090719124819.GE5407@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sun, Jul 19, 2009 at 11:15:39AM +0100, Pedro Doria Meunier wrote:
> I have a table ~18M rows with a 'timestamp with time zone' column. It's
> indexed thus:
>
> CREATE INDEX my_table_timestamp_idx
> ON my_table
> USING btree
> (zulu_timestamp);

Based on your query, I think you want a multi-column index---probably on
(id,zulu_timestamp).

The problem with just having an index on either column is that it's
difficult to combine them and PG hence just thinks that it will be
easier to scan backwards in time looking for the first entry for the
identifier you specified.

BTW, if you're concerned about insert performance then the less indexes
you have the better.

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2009-07-19 12:56:04 Re: Timestamp indicies not being used!
Previous Message Andreas Kretschmer 2009-07-19 11:48:18 Re: Timestamp indicies not being used!