X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id 88E6C9DCBFB for ; Fri, 10 Feb 2006 02:05:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 33782-08 for ; Fri, 10 Feb 2006 02:05:51 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from stark.xeocode.com (stark.xeocode.com [216.58.44.227]) by postgresql.org (Postfix) with ESMTP id 8C5129DCBCA for ; Fri, 10 Feb 2006 02:05:50 -0400 (AST) Received: from localhost ([127.0.0.1] helo=stark.xeocode.com) by stark.xeocode.com with smtp (Exim 3.36 #1 (Debian)) id 1F7RPa-0001TK-00; Fri, 10 Feb 2006 01:05:42 -0500 To: Tom Lane Cc: Rafael Martinez Guerrero , pgsql-performance@postgresql.org Subject: Re: Help with optimizing a sql statement References: <1139497827.25608.1014.camel@bbking.uio.no> <5731.1139527320@sss.pgh.pa.us> In-Reply-To: <5731.1139527320@sss.pgh.pa.us> From: Greg Stark Organization: The Emacs Conspiracy; member since 1992 Date: 10 Feb 2006 01:05:42 -0500 Message-ID: <87zmkz6955.fsf@stark.xeocode.com> Lines: 19 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.131 required=5 tests=[AWL=0.131] X-Spam-Score: 0.131 X-Spam-Level: X-Archive-Number: 200602/93 X-Sequence-Number: 17079 Tom Lane writes: > Are you sure this WHERE clause really expresses your intent? It seems > awfully oddly constructed. Removing the redundant parens and clarifying > the layout, I get ... > That next-to-last major AND clause seems a rather unholy mix of join and > restriction clauses; I wonder if it's not buggy in itself. FYI RT uses a perl module called SearchBuilder which constructs these queries dynamically. So he's probably not really free to fiddle with the query all he wants. At the very least I would suggest checking the changelog for SearchBuilder for more recent versions. There have been a lot of tweaks for working with Postgres. In the past it really only worked properly with MySQL. -- greg