pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Andrew McMillan <andrew@catalyst.net.nz>
To: Antony Paul <antonypaul24@gmail.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: Checking = with timestamp field is slow
Date: Fri, 05 Nov 2004 21:48:59 +1300
Message-ID: <1099644539.7326.346.camel@lamb.mcmillan.net.nz> (raw)
In-Reply-To: <2989532e0411042316566b35f4@mail.gmail.com>
References: <2989532e0411042316566b35f4@mail.gmail.com>

On Fri, 2004-11-05 at 12:46 +0530, Antony Paul wrote:
> Hi all,
>    I have a table which have more than 200000 records. I need to get
> the records which matches like this
> 
> where today::date = '2004-11-05';
> 
> This is the only condition in the query. There is a btree index on the
> column today.
> Is there any way to optimise it.

Hi Antony,

I take it your field is called "today" (seems dodgy, but these things
happen...).  Anywa, have you tried indexing on the truncated value?

  create index xyz_date on xyz( today::date );
  analyze xyz;

That's one way.  It depends on how many of those 200,000 rows are on
each date too, as to whether it will get used by your larger query.

Regards,
					Andrew.

-------------------------------------------------------------------------
Andrew @ Catalyst .Net .NZ  Ltd,  PO Box 11-053, Manners St,  Wellington
WEB: http://catalyst.net.nz/            PHYS: Level 2, 150-154 Willis St
DDI: +64(4)803-2201      MOB: +64(272)DEBIAN      OFFICE: +64(4)499-2267
      When in doubt, tell the truth.
                -- Mark Twain
-------------------------------------------------------------------------

Attachments:

  signature.asc (application/pgp-signature, 188B) download

view thread (8+ messages)  latest in thread

Message-ID: <1099644539.7326.346.camel@lamb.mcmillan.net.nz>
Permalink:  ../1099644539.7326.346.camel@lamb.mcmillan.net.nz/
Also on:    postgresql.org/message-id/1099644539.7326.346.camel@lamb.mcmillan.net.nz

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-performance@postgresql.org
  Cc: andrew@catalyst.net.nz, antonypaul24@gmail.com
  Subject: Re: Checking = with timestamp field is slow
  In-Reply-To: <1099644539.7326.346.camel@lamb.mcmillan.net.nz>
  References: <2989532e0411042316566b35f4@mail.gmail.com> <1099644539.7326.346.camel@lamb.mcmillan.net.nz>

* 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