Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id E0CBB1337B84 for ; Sat, 8 Jan 2011 15:05:20 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 39305-02 for ; Sat, 8 Jan 2011 19:05:13 +0000 (UTC) X-Greylist: delayed 00:12:31.512469 by SQLgrey-1.7.6 Received: from eastrmmtai104.cox.net (eastrmmtai104.cox.net [68.230.240.11]) by mail.postgresql.org (Postfix) with ESMTP id 547B81337B4E for ; Sat, 8 Jan 2011 15:05:12 -0400 (AST) Received: from eastrmimpo02.cox.net ([68.1.16.120]) by eastrmmtao106.cox.net (InterMail vM.8.01.03.00 201-2260-125-20100507) with ESMTP id <20110108185238.LMPR7953.eastrmmtao106.cox.net@eastrmimpo02.cox.net>; Sat, 8 Jan 2011 13:52:38 -0500 Received: from frank ([68.106.96.96]) by eastrmimpo02.cox.net with bizsmtp id t6se1f00224lncc026se5V; Sat, 08 Jan 2011 13:52:38 -0500 X-VR-Score: -130.00 X-Authority-Analysis: v=1.1 cv=i3UvcCEZQLabEmnD6gDaX0mba1mClu3kqrscycMm7eQ= c=1 sm=1 a=WF8kTlOsmXkA:10 a=kj9zAlcOel0A:10 a=muDt//BAoVvL/zWUOsKdBw==:17 a=epTmVMiNAAAA:8 a=rOc0U4YfAAAA:8 a=Ex6FEnyyq7MNSVYHFq8A:9 a=W05n0Yr5BHA_r9jrgetf9iNYyC0A:4 a=CjuIK1q_8ugA:10 a=YObXiYvaVLwA:10 a=IIT2Ns--uMIA:10 a=N5QpJeutspKsUsL1:21 a=I4QkfSdh3qmhF0vB:21 a=muDt//BAoVvL/zWUOsKdBw==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; none From: "frank" To: "'Kevin Grittner'" , Subject: Re: BUG #5816: index not used in function Date: Sat, 8 Jan 2011 13:52:38 -0500 Message-ID: <000001cbaf65$38a8dee0$6900a8c0@frank> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.2627 Importance: Normal In-Reply-To: <4D25AC7A0200002500039079@gw.wicourts.gov> X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2869 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201101/70 X-Sequence-Number: 29092 Kevin, Very thrilled to hear back from you (and surprised at the promptness, too)! Please do not take this personal as it is a tech issue and I am treating it thus. 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. 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'. I gave specific parameters in my example (if you go back to my original email/bug report). To be precise, the parameter does not start with a wild card. By giving '%X%', you may have changed the nature a bit. Regardless, it is still the same issue: the implementation did not faithfully reflect the specification, which did not explicitly (nor implicitly) endorse such behavior. From a tech perspective, you are actually partially correct, but only partially. How can a leading wild-card warrant the use of index? It can not, for sure. However, the implementation is still defective. Let me be specific. The logic should be a conditional: if (at run time when the argument is parsed and examined) a leading wild-card is found, it should branch to not use index (as it can not), otherwise it should. The compilation already sees the text [upper("thisColumn")]. Assuming there are no other issues and embedded wild-cards are correctly handled (e.g. through index search and then a filter), the above described simple logic is the only thing needed to be thrown in. 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. Lastly, to expose it as a work-around, let us take the situation where I input n parameters, the different combinations will be used to query against a number of tables (inside the function). Due to the issue, I have to input all the actual query text as parameters into the function (which by now is no longer truly a function). But that could be factorial! Anyway, I hope this can be re-considered. I do not want to create headaches, but if resource constraint is a factor, I may offer to fix the problem if you could kindly provide with your lexer code and the code files that are/may be affected, as well as POC for QA. Once again, I appreciate your reply and thank you for the attention. Regards, Frank -----Original Message----- From: Kevin Grittner [mailto:Kevin.Grittner@wicourts.gov] Sent: Thursday, January 06, 2011 12:50 PM To: pgsql-bugs@postgresql.org; frank Subject: Re: [BUGS] BUG #5816: index not used in function "frank" wrote: > WHERE upper("thisColumn") like $1 The function's plan is kept from one execution to another, and it can't know what will be in the first parameter -- perhaps '%X%'? If you build up the statement in a string and EXECUTE it, you might get the desired behavior. Anyway, next time you have an issue like this, please post to the performance list; this is not a bug. -Kevin