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

Re: Forcing filter/join order?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: josh(at)agliodbs(dot)com
Cc: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>,pgsql-performance <pgsql-performance(at)postgresql(dot)org>
Subject: Re: Forcing filter/join order?
Date: 2004-02-19 05:08:19
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-performance
Josh Berkus <josh(at)agliodbs(dot)com> writes:
> Knowing that events are never more than one month long for this
> application, I can do:

> "WHERE event.event_date >= (begin_date - '1 month) AND event.event_date <= 
> end_date"

> ... which works because I have a child table which has event information by 
> day:

Uh, why do you need the child table?  Seems like the correct incantation
given an assumption about maximum duration is

event_date <= 'end-date' AND (event_date + duration) >= 'start-date'
AND event_date >= 'start-date' - 'max-duration'

The last clause is redundant with the one involving the duration field,
but it provides a lower bound for the index scan on event_date.  The
only index you really need here is one on event_date, but possibly one
on (event_date, (event_date + duration)) would be marginally faster.

			regards, tom lane

In response to


pgsql-performance by date

Next:From: Saleem Burhani BalochDate: 2004-02-19 09:01:20
Subject: Re: Slow response of PostgreSQL
Previous:From: Josh BerkusDate: 2004-02-19 04:56:47
Subject: Re: Tables on multiple disk drives

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group