X-Original-To: pgsql-performance-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id C511452806 for ; Wed, 25 May 2005 17:19:03 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 97607-03 for ; Wed, 25 May 2005 20:18:56 +0000 (GMT) Received: from server07.icaen.uiowa.edu (server07.icaen.uiowa.edu [128.255.17.47]) by svr1.postgresql.org (Postfix) with ESMTP id 9336152803 for ; Wed, 25 May 2005 17:18:54 -0300 (ADT) Received: from server11.icaen.uiowa.edu (server11.icaen.uiowa.edu [128.255.17.51]) by server07.icaen.uiowa.edu (8.13.3/8.12.9) with ESMTP id j4PKIr0H024065; (envelope-from ) Wed, 25 May 2005 15:18:53 -0500 (CDT) Received: from [192.168.1.11] (12-215-118-172.client.mchsi.com [12.215.118.172]) (authenticated user=jfmeinel) by server11.icaen.uiowa.edu (8.13.2/smtp-serv-1.7) with ESMTP id j4PKIqlJ005509 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256); (envelope-from ) Wed, 25 May 2005 15:18:52 -0500 (CDT) Message-ID: <4294DDAC.1060908@arbash-meinel.com> Date: Wed, 25 May 2005 15:18:52 -0500 From: John A Meinel User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Jocelyn Turcotte Cc: pgsql-performance@postgresql.org Subject: Re: Inner join on two OR conditions dont use index References: <688c0b7505052513127df47894@mail.gmail.com> In-Reply-To: <688c0b7505052513127df47894@mail.gmail.com> X-Enigmail-Version: 0.91.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigBA2C45A3BD41EF23FF6EC9B5" X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Scanned: ClamAV version 0.83, clamav-milter version 0.83 on clamav.icaen.uiowa.edu X-Virus-Status: Clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200505/390 X-Sequence-Number: 12554 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigBA2C45A3BD41EF23FF6EC9B5 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Jocelyn Turcotte wrote: >Hi all >i dont know if this is normal, but if yes i would like to know why and >how I could do it another way other than using unions. > > The only thing that *might* work is if you used an index on both keys. So if you did: CREATE INDEX rt_edge_start_end_node ON rt_edge(start_node_id,end_node_id); The reason is that in an "OR" construct, you have to check both for being true. So in the general case where you don't know the correlation between the columns, you have to check all of the entries, because even if you know the status of one side of the OR, you don't know the other. Another possibility would be to try this index: CREATE INDEX rt_edge_stare_or_end ON rt_edge(start_node_id OR end_node_id); I'm not sure how smart the planner can be, though. John =:-> --------------enigBA2C45A3BD41EF23FF6EC9B5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFClN2sJdeBCYSNAAMRAkE2AJ98+ARuCFZwm8ndvmzXAgJcVi8SOgCfUTN+ p+XUzT34SFKm2f3JjUiyCnU= =imqt -----END PGP SIGNATURE----- --------------enigBA2C45A3BD41EF23FF6EC9B5--