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 BE0789DCA2C for ; Thu, 9 Feb 2006 19:35:06 -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 60422-07 for ; Thu, 9 Feb 2006 19:35:08 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from pat.uio.no (pat.uio.no [129.240.130.16]) by postgresql.org (Postfix) with ESMTP id 271739DC951 for ; Thu, 9 Feb 2006 19:35:04 -0400 (AST) Received: from mail-mx5.uio.no ([129.240.10.46]) by pat.uio.no with esmtp (Exim 4.43) id 1F7LJa-0006M0-Ez; Fri, 10 Feb 2006 00:35:06 +0100 Received: from ti200710a080-12451.bb.online.no ([85.164.176.163] helo=[10.1.1.101]) by mail-mx5.uio.no with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.43) id 1F7LJX-00065c-Qt; Fri, 10 Feb 2006 00:35:03 +0100 Subject: Re: Help with optimizing a sql statement From: Rafael Martinez To: Tom Lane Cc: pgsql-performance@postgresql.org In-Reply-To: <5731.1139527320@sss.pgh.pa.us> References: <1139497827.25608.1014.camel@bbking.uio.no> <5731.1139527320@sss.pgh.pa.us> Content-Type: text/plain Organization: University of Oslo Date: Fri, 10 Feb 2006 00:36:34 +0100 Message-Id: <1139528194.19758.18.camel@linux.site> Mime-Version: 1.0 X-Mailer: Evolution 2.4.0 Content-Transfer-Encoding: 7bit X-UiO-Spam-info: not spam, SpamAssassin (score=-4.274, required 12, autolearn=disabled, AWL 0.73, UIO_MAIL_IS_INTERNAL -5.00) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.12 required=5 tests=[AWL=0.120] X-Spam-Score: 0.12 X-Spam-Level: X-Archive-Number: 200602/91 X-Sequence-Number: 17077 On Thu, 2006-02-09 at 18:22 -0500, Tom Lane wrote: > Rafael Martinez Guerrero writes: > > WHERE ((ACL_2.RightName = 'OwnTicket')) > > AND ((CachedGroupMembers_4.MemberId = Principals_1.id)) > > AND ((Groups_3.id = CachedGroupMembers_4.GroupId)) > > AND ((Principals_1.Disabled = '0') or (Principals_1.Disabled = '0')) > > AND ((Principals_1.id != '1')) > > AND ((main.id = Principals_1.id)) > > AND ( ( ACL_2.PrincipalId = Groups_3.id AND ACL_2.PrincipalType = > > 'Group' AND ( Groups_3.Domain = 'SystemInternal' OR Groups_3.Domain = > > 'UserDefined' OR Groups_3.Domain = 'ACLEquivalence')) OR ( ( > > (Groups_3.Domain = 'RT::Queue-Role' ) ) AND Groups_3.Type > > =ACL_2.PrincipalType) ) > > AND (ACL_2.ObjectType = 'RT::System' OR (ACL_2.ObjectType = 'RT::Queue') > > ) > > 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 > [............] This is an application that we have not programmed, so I am not sure what they are trying to do here. I will contact the developers. Tomorrow I will try to test some of your suggestions. > BTW, what PG version is this? It looks to me like it's doing some > manipulations of the WHERE clause that we got rid of a couple years ago. > If this is 7.4 or older then you really ought to be thinking about an > update. > We are running 7.4.8 in this server and will upgrade to 8.0.6 in a few weeks. Thanks. -- Rafael Martinez, Center for Information Technology Services University of Oslo, Norway PGP Public Key: http://folk.uio.no/rafael/