pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: Stephan Szabo <sszabo@megazone.bigpanda.com>
Cc: pgsql-performance <pgsql-performance@postgresql.org>
Subject: Re: Forcing filter/join order?
Date: Wed, 18 Feb 2004 17:18:22 -0800
Message-ID: <200402181718.22687.josh@agliodbs.com> (raw)
In-Reply-To: <20040218165410.G36125@megazone.bigpanda.com>
References: <200402181610.31978.josh@agliodbs.com>
	<200402181630.43503.josh@agliodbs.com>
	<20040218165410.G36125@megazone.bigpanda.com>

Stephan,

> Can you give more information?  I know that I'm not exactly certain what
> the situation is from the above and the original query/explain piece.
> 

Believe me, if I posted the query it wouldn't help.    Heck, I'd have trouble 
following it without my notes.

a simplifed version:

SELECT events.*, cases.case_name
FROM events LEFT OUTER JOIN cases ON events.case_id = cases.case_id
WHERE (event_date >= '2004-03-05' OR (event_date + duration) <= '2004-02-18')
	AND events.status <> 0;

... this is to get me all vaild events which overlap with the range 
'2004-02-18' to '2004-03-05'.

I had thought, in 7.4, that adding an index on (event_date, (event_date + 
duration)) would improve the execution of this query.   It doesn't, 
presumably because the multi-column index can't be used for both ascending 
and descending sorts at the same time, and event_date >= '2004-03-05' isn't 
selective enough.

There was a workaround for this posted on hackers about a year ago as I 
recally, that involved creating custom operators for indexing.  Too much 
trouble when there's a hackish workaround (due to the fact that events have 
to be less than a month long).

-- 
-Josh Berkus
 Aglio Database Solutions
 San Francisco




view thread (12+ messages)  latest in thread

Message-ID: <200402181718.22687.josh@agliodbs.com>
Permalink:  ../200402181718.22687.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200402181718.22687.josh@agliodbs.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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: josh@agliodbs.com, sszabo@megazone.bigpanda.com
  Subject: Re: Forcing filter/join order?
  In-Reply-To: <200402181718.22687.josh@agliodbs.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