X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 03AA930E803 for ; Thu, 12 Jun 2003 12:04:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 52628-08 for ; Thu, 12 Jun 2003 09:04:35 -0300 (ADT) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 458BA30E802 for ; Thu, 12 Jun 2003 09:04:35 -0300 (ADT) Received: (qmail 1421 invoked by uid 500); 12 Jun 2003 12:07:22 -0000 Date: Thu, 12 Jun 2003 07:07:22 -0500 From: Bruno Wolff III To: Marco Vezzoli Cc: pgsql-sql@postgresql.org Subject: Re: multiple index search with postgres7.1.3 on solaris 8 Message-ID: <20030612120722.GB1285@wolff.to> Mail-Followup-To: Marco Vezzoli , pgsql-sql@postgresql.org References: <3EE8621D.F6A261AE@st.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3EE8621D.F6A261AE@st.com> User-Agent: Mutt/1.5.4i X-Archive-Number: 200306/102 X-Sequence-Number: 13860 On Thu, Jun 12, 2003 at 13:21:01 +0200, Marco Vezzoli wrote: > Hi everybody, > I'm sorry if this topic has already been explained, but the search > engine at archives.postgresql.org shows me 10 pages of results but > without any link (!). > I'm using postgres 7.1.3 on Solaris 8; I would like to do some query of > this form > > SELECT * FROM table WHERE (attribute1,attribute2) IN > ((value1_0,value2_0),(value1_1,value2_1) ...) > > (which is legal on oracle 8i on solaris 8). > I know this has an equivalent boolean expression but: > -I would like to use an index defined like > CREATE INDEX myindex ON table(attribute1,attribute2) > -the pairs in the list can be many (up to 100) or'ing IN terms together is probably going to result in the same plan that you are describing above (assuming table has a large enough number of rows). I don't know if this way of writing the query can generate a sort of values you are checking against and then a merge join. For just a hundred or so values I don't think this plan would be that much better than both nest loop and multiple index scans. However, if you want to get that plan and or'ing INs won't generate it, then you could try union'ing the values together in the IN value list. 7.4 will likely behave differently than pre 7.4 versions.