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 61B0F52934 for ; Thu, 23 Jun 2005 05:33:23 -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 81922-06 for ; Thu, 23 Jun 2005 08:33:18 +0000 (GMT) Received: from matlab.pharmadm.com (derma.pharmadm.com [193.190.169.32]) by svr1.postgresql.org (Postfix) with ESMTP id 74A12528D9 for ; Thu, 23 Jun 2005 05:33:17 -0300 (ADT) Received: from [192.168.93.22] (matlab.pharmadm.com [192.168.93.22]) by matlab.pharmadm.com (Postfix) with ESMTP id D12D9BCE5; Thu, 23 Jun 2005 10:33:18 +0200 (CEST) Message-ID: <42BA73CE.4030909@student.kuleuven.ac.be> Date: Thu, 23 Jun 2005 10:33:18 +0200 From: Kurt De Grave User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Josh Berkus Cc: pgsql-performance@postgresql.org Subject: Re: parameterized LIKE does not use index Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests= X-Spam-Level: X-Archive-Number: 200506/447 X-Sequence-Number: 13084 > > Of course, I could modify the application and send different SQL > > depending on which case we're in or just constructing a query with a > > literal each time, but is there a way to add a hint to the SQL that > > would cause the query to be re-planned if it's a case that could use the > > index? Or can I convince the (Perl) driver to do so? > There should be an option to tell DBD::Pg not to cache a query plan. > Let's see .... > > yes. pg_server_prepare=0, passed to the prepare() call. That does the trick! Now I can have the cake and eat it! (clean code and high perf) Now it's tempting to dream of some mechanism that could make the database consider replanning the query automatically once it knows the parameter, or choose from a set of plans depending on the parameter. In this case the general plan was about three orders of magnitude slower than the specialized plan. But I guess this case is not all that common and the developer can work around it. thanks, kurt. -- ir. Kurt De Grave http://www.PharmaDM.com PharmaDM nv. phone: +32-16-298494 Kapeldreef 60, B-3001 Leuven, Belgium fax: +32-16-298490