Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Index isn't used during a join.


  • From: Michael Fuhr <mike(at)fuhr(dot)org>
  • To: Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
  • Cc: PGPerformance <pgsql-performance(at)postgresql(dot)org>
  • Subject: Re: Index isn't used during a join.
  • Date: Wed, 11 Jan 2006 02:00:08 -0700
  • Message-id: <20060111090008.GA51672@winnie.fuhr.org> <text/plain>

On Wed, Jan 11, 2006 at 12:56:55AM -0700, Michael Fuhr wrote:
> WHERE ...
>   AND doy >= EXTRACT(doy FROM now() - '24 hour'::interval)
>   AND doy <= EXTRACT(doy FROM now())

To work on 1 Jan this should be more like

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

In any case the point is to add conditions to the WHERE clause that
will use an index on the table for which you're currently getting
a sequential scan.

-- 
Michael Fuhr



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group