pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Robert Creager <Robert_Creager@LogicalChaos.org>
Cc: PGPerformance <pgsql-performance@postgresql.org>
Subject: Re: Index isn't used during a join.
Date: Wed, 11 Jan 2006 00:56:55 -0700
Message-ID: <20060111075655.GA51292@winnie.fuhr.org> (raw)
In-Reply-To: <20060110221055.053596ab@thunder.logicalchaos.org>
References: <20060109212338.6420af12@thunder.logicalchaos.org>
	<20060110055818.GA55076@winnie.fuhr.org>
	<20060110221055.053596ab@thunder.logicalchaos.org>

On Tue, Jan 10, 2006 at 10:10:55PM -0700, Robert Creager wrote:
> The query is now correct, but still is slow because of lack of
> index usage.  I don't know how to structure the query correctly to
> use the index.

Have you tried adding restrictions on doy in the WHERE clause?
Something like this, I think:

WHERE ...
  AND doy >= EXTRACT(doy FROM now() - '24 hour'::interval)
  AND doy <= EXTRACT(doy FROM now())

Something else occurred to me: do you (or will you) have more than
one year of data?  If so then matching on doy could be problematic
unless you also check for the year, or unless you want to match
more than one year.

-- 
Michael Fuhr



view thread (11+ messages)  latest in thread

Message-ID: <20060111075655.GA51292@winnie.fuhr.org>
Permalink:  ../20060111075655.GA51292@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20060111075655.GA51292@winnie.fuhr.org

 · 

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: mike@fuhr.org, Robert_Creager@LogicalChaos.org
  Subject: Re: Index isn't used during a join.
  In-Reply-To: <20060111075655.GA51292@winnie.fuhr.org>

* 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