X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 804C7D1E0CD for ; Thu, 19 Feb 2004 01:19:12 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 62220-08 for ; Wed, 18 Feb 2004 21:19:13 -0400 (AST) Received: from davinci.ethosmedia.com (server228.ethosmedia.com [209.128.84.228]) by svr1.postgresql.org (Postfix) with ESMTP id 51400D1E0C7 for ; Wed, 18 Feb 2004 21:19:10 -0400 (AST) Received: from [63.195.55.98] (HELO 192.168.1.29) by davinci.ethosmedia.com (CommuniGate Pro SMTP 4.0.2) with ESMTP id 4453754; Wed, 18 Feb 2004 17:20:19 -0800 From: Josh Berkus Reply-To: josh@agliodbs.com Organization: Aglio Database Solutions To: Stephan Szabo Subject: Re: Forcing filter/join order? Date: Wed, 18 Feb 2004 17:18:22 -0800 User-Agent: KMail/1.5.4 Cc: pgsql-performance References: <200402181610.31978.josh@agliodbs.com> <200402181630.43503.josh@agliodbs.com> <20040218165410.G36125@megazone.bigpanda.com> In-Reply-To: <20040218165410.G36125@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200402181718.22687.josh@agliodbs.com> X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/215 X-Sequence-Number: 5739 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