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 9D9175281B for ; Tue, 5 Jul 2005 14:49:41 -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 51716-02 for ; Tue, 5 Jul 2005 17:49:30 +0000 (GMT) Received: from relais.videotron.ca (relais.videotron.ca [24.201.245.36]) by svr1.postgresql.org (Postfix) with ESMTP id BFB7752814 for ; Tue, 5 Jul 2005 14:49:23 -0300 (ADT) Received: from [192.168.1.101] ([24.202.23.128]) by VL-MO-MR007.ip.videotron.ca (iPlanet Messaging Server 5.2 HotFix 1.21 (built Sep 8 2003)) with ESMTP id <0IJ600A931G2MU@VL-MO-MR007.ip.videotron.ca> for pgsql-performance@postgresql.org; Tue, 05 Jul 2005 13:48:02 -0400 (EDT) Date: Tue, 05 Jul 2005 13:53:59 -0400 From: David Gagnon Subject: Re: Why the planner is not using the INDEX . In-reply-to: <23492.1120579796@sss.pgh.pa.us> To: Tom Lane Cc: pgsql-performance@postgresql.org Message-id: <42CAC937.4080702@siunik.com> MIME-version: 1.0 Content-type: text/plain; charset=ISO-8859-1; format=flowed Content-transfer-encoding: 7BIT X-Accept-Language: en-us, en User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) References: <20050630222451.GA17628@calvin.surfutopia.net> <42C473BA.9090305@commandprompt.com> <20050630235821.GA2163@calvin.surfutopia.net> <42C994BD.3000909@siunik.com> <23492.1120579796@sss.pgh.pa.us> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.126 tagged_above=0 required=5 tests=AWL, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200507/41 X-Sequence-Number: 13282 Tom Lane wrote: >David Gagnon writes: > > >> explain analyse SELECT IRNUM FROM IR >> INNER JOIN IT ON IT.ITIRNUM = ANY ('{1000, 2000}') AND >>IT.ITYPNUM = 'M' AND IR.IRYPNUM = IT.ITYPNUM AND IR.IRNUM = IT.ITIRNUM >> WHERE IRNUM = ANY ('{1000, 2000}') and IRYPNUM = 'M' >> >> > >Those =ANY constructs are not currently optimizable at all. You might >get better results with "IT.ITIRNUM IN (1000, 2000)" etc. > > regards, tom lane > > > I already tried this construct. But the statement comes from a stored procedure where the {1000, 2000} is an array variable (requestIds). I tried to use IT.ITIRNUM IN (requestIds) or several other variant without success. Is there a way to make it work? Here is the statement the statement from the store procedure. Remenber requestIds is an array of int. FOR inventoryTransaction IN SELECT DISTINCT IRNUM, IRAENUM, IRSTATUT, IRSENS, IRSOURCE, IRDATE, IRQTE FROM IR WHERE IRNUM = ANY (requestIds) and IRYPNUM = companyId LOOP Thank for your help !!!! /David