Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id C93B31337990 for ; Sun, 9 Jan 2011 15:41:06 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 48035-02 for ; Sun, 9 Jan 2011 19:40:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og111.obsmtp.com (exprod7og111.obsmtp.com [64.18.2.175]) by mail.postgresql.org (Postfix) with ESMTP id 2D5C21337B84 for ; Sun, 9 Jan 2011 15:40:59 -0400 (AST) Received: from source ([209.85.216.176]) (using TLSv1) by exprod7ob111.postini.com ([64.18.6.12]) with SMTP ID DSNKTSoPShLL1KpFyn8hj9wucm0WF9Kbz2Dj@postini.com; Sun, 09 Jan 2011 11:40:59 PST Received: by qyk10 with SMTP id 10so19302645qyk.0 for ; Sun, 09 Jan 2011 11:40:57 -0800 (PST) Received: by 10.224.37.7 with SMTP id v7mr14561430qad.91.1294601622767; Sun, 09 Jan 2011 11:33:42 -0800 (PST) Received: from [192.168.2.36] (va-76-4-65-131.sta.embarqhsd.net [76.4.65.131]) by mx.google.com with ESMTPS id t7sm15706047qcs.40.2011.01.09.11.33.40 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 09 Jan 2011 11:33:41 -0800 (PST) Subject: Re: BUG #5816: index not used in function Mime-Version: 1.0 (Apple Message framework v1082) Content-Type: text/plain; charset=us-ascii From: Korry Douglas X-Priority: 3 (Normal) In-Reply-To: <000001cbaf65$38a8dee0$6900a8c0@frank> Date: Sun, 9 Jan 2011 14:33:38 -0500 Cc: "'Kevin Grittner'" , Content-Transfer-Encoding: quoted-printable Message-Id: References: <000001cbaf65$38a8dee0$6900a8c0@frank> To: frank X-Mailer: Apple Mail (2.1082) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-4.2 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3 X-Spam-Level: X-Archive-Number: 201101/72 X-Sequence-Number: 29094 > We may have different perceptions of something being a 'bug'. I always > have several simple ways of determining it. One of them is when a > work-around is in the proposal. Yours is one. It seems to me that the important question in this case is whether or = not the query produced the correct result. You are complaining about a performance issue, not a correctness issue, = right? Kevin's work-around is meant to help you *gain better performance*, not = to obtain correct results when you are getting incorrect results. > There can be quite a number of ways of looking at the issue. First, it > is truly an implementation matter (making it in the true sense a bug). = I > do not believe that the spec would in formal way say that 'well, there > are caveats where you have to do this and that to work around'. The "spec" (by which I assume you mean the SQL standard) says nothing = about which execution plan will be selected the optimizer. > > If by 'kept from one execution to another' means that (the concept of) = a > plan is implemented static, this can be a low level design issue, = which > in general will still be regarded as implementation, thus a bug. The execution plan is not quite static - it is computed the first time = you run the function (within a session) and is discarded when your = session ends (or when the compiled function/execution plan becomes = obsolete because of a change to a dependency). That is by design. If you want a dynamic plan that is re-computed each time you execute the = query, you can get that behavior by using dynamic SQL, as Kevin = suggested. -- Korry