[PERFORM] parameterized LIKE does not use index

2005-06-27 Thread Kurt De Grave
Hi, Consider the where-clauses: WHERE lower(col) LIKE 'abc'; WHERE lower(col) LIKE 'abc%'; these will both use a b-tree functional index in lower(col) if one exists. The clause WHERE lower(col) LIKE '%abc'; can't use the index as you would expect, because of the wildcard at the front (as

Re: [PERFORM] parameterized LIKE does not use index

2005-06-24 Thread Jim C. Nasby
On Thu, Jun 23, 2005 at 11:55:35AM -0700, Josh Berkus wrote: Bruno, I remember some discussion about delaying planning until the first actual query so that planning could use actual parameters to do the planning. If you really want to have it check the parameters every time, I think you

Re: [PERFORM] parameterized LIKE does not use index

2005-06-23 Thread Kurt De Grave
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

Re: [PERFORM] parameterized LIKE does not use index

2005-06-23 Thread Bruno Wolff III
On Thu, Jun 23, 2005 at 10:33:18 +0200, Kurt De Grave [EMAIL PROTECTED] wrote: 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

Re: [PERFORM] parameterized LIKE does not use index

2005-06-23 Thread Josh Berkus
Bruno, I remember some discussion about delaying planning until the first actual query so that planning could use actual parameters to do the planning. If you really want to have it check the parameters every time, I think you will need to replan every time. I don't know if there is a way to

[PERFORM] parameterized LIKE does not use index

2005-06-22 Thread Kurt De Grave
Hi, Consider the where-clauses: WHERE lower(col) LIKE 'abc'; WHERE lower(col) LIKE 'abc%'; these will both use a b-tree functional index in lower(col) if one exists. The clause WHERE lower(col) LIKE '%abc'; can't use the index as you would expect, because of the wildcard at the front. Thus,

Re: [PERFORM] parameterized LIKE does not use index

2005-06-22 Thread Josh Berkus
Kurt, 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