Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 401A59FB9C9 for ; Tue, 10 Jul 2007 14:24:33 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 04916-02 for ; Tue, 10 Jul 2007 14:24:25 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id D8CB29FB8C9 for ; Tue, 10 Jul 2007 14:24:26 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.1/8.14.1) with ESMTP id l6AHOOu8002512; Tue, 10 Jul 2007 13:24:24 -0400 (EDT) To: Patrick.Clery@gmail.com cc: pgsql-sql@postgresql.org Subject: Re: Index working, but not inside function In-reply-to: <200707100038.15237.Patrick.Clery@gmail.com> References: <200707100038.15237.Patrick.Clery@gmail.com> Comments: In-reply-to Patrick Clery message dated "Tue, 10 Jul 2007 00:38:12 -0600" Date: Tue, 10 Jul 2007 13:24:24 -0400 Message-ID: <2511.1184088264@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/48 X-Sequence-Number: 28783 Patrick Clery writes: > When I execute the function the query stalls and is apparently not taking > advantage of the index. Your example doesn't demonstrate any such thing; what seems more likely is that there are a whole lot of rows matching 'United States' and so the query takes longer than you expect. What would be convincing is if you had actually *executed* the prepared query, on the same data not different data, and timed that. regards, tom lane