pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Merlin Moncure <mmoncure@gmail.com>
To: Dan Harris <fbsd@drivefaster.net>
Cc: PostgreSQL Performance <pgsql-performance@postgresql.org>
Subject: Re: Help optimizing a slow index scan
Date: Fri, 17 Mar 2006 11:56:03 -0500
Message-ID: <b42b73150603170856j588b268bjd89ce769f4ac7a28@mail.gmail.com> (raw)
In-Reply-To: <4419DB50.10404@drivefaster.net>
References: <4419DB50.10404@drivefaster.net>

On 3/16/06, Dan Harris <fbsd@drivefaster.net> wrote:
> explain analyze
> select distinct eventmain.incidentid, eventmain.entrydate,
> eventgeo.long, eventgeo.lat, eventgeo.geox, eventgeo.geoy
> from eventmain, eventgeo
> where
>     eventmain.incidentid = eventgeo.incidentid and
>     ( long > -104.998027962962 and long < -104.985957781349 ) and
>     ( lat > 39.7075542720006 and lat < 39.7186195832938 ) and
>     eventmain.entrydate > '2006-1-1 00:00' and
>     eventmain.entrydate <= '2006-3-17 00:00'
> order by
>     eventmain.entrydate;

As others will probably mention, effective queries on lot/long which
is a spatial problem will require r-tree or gist.  I don't have a lot
of experience with exotic indexes but this may be the way to go.

One easy optimization to consider making is to make an index on either
(incidentid, entrydate) or (incident_id,long) which ever is more
selective.

This is 'yet another query' that would be fun to try out and tweak
using the 8.2 upcoming row-wise comparison.

merlin



view thread (15+ messages)  latest in thread

Message-ID: <b42b73150603170856j588b268bjd89ce769f4ac7a28@mail.gmail.com>
Permalink:  ../b42b73150603170856j588b268bjd89ce769f4ac7a28@mail.gmail.com/
Also on:    postgresql.org/message-id/b42b73150603170856j588b268bjd89ce769f4ac7a28@mail.gmail.com

 · 

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: mmoncure@gmail.com, fbsd@drivefaster.net
  Subject: Re: Help optimizing a slow index scan
  In-Reply-To: <b42b73150603170856j588b268bjd89ce769f4ac7a28@mail.gmail.com>
  References: <4419DB50.10404@drivefaster.net> <b42b73150603170856j588b268bjd89ce769f4ac7a28@mail.gmail.com>

* 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