Re: [SQL] Best Fit SQL query statement

2007-08-14 Thread Fernando Hevia
De: hubert depesz lubaczewski [mailto:[EMAIL PROTECTED] >>On Fri, Aug 10, 2007 at 04:40:34PM -0300, Fernando Hevia wrote: >> Found your query is shorter and clearer, problem is I couldn't have it use >> an index. Thought it was a locale issue but adding a 2nd index with >> varchar_pattern_ops ma

Re: [SQL] Best Fit SQL query statement

2007-08-11 Thread hubert depesz lubaczewski
On Fri, Aug 10, 2007 at 08:13:46PM -0500, Rodrigo De León wrote: > On 8/10/07, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > > unfortunatelly this query will be hard to optimize. > > Uh, how about > > SELECT MAX(t1) > FROM t1 > WHERE '9849' LIKE t1 || '%'; it will not help much as th

Re: [SQL] Best Fit SQL query statement

2007-08-10 Thread Rodrigo De León
On 8/10/07, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > unfortunatelly this query will be hard to optimize. Uh, how about SELECT MAX(t1) FROM t1 WHERE '9849' LIKE t1 || '%'; ---(end of broadcast)--- TIP 6: explain analyze is your frie

Re: [SQL] Best Fit SQL query statement

2007-08-10 Thread hubert depesz lubaczewski
On Fri, Aug 10, 2007 at 04:40:34PM -0300, Fernando Hevia wrote: > Found your query is shorter and clearer, problem is I couldn't have it use > an index. Thought it was a locale issue but adding a 2nd index with > varchar_pattern_ops made no difference. > In result, it turned out to be too slow in c

Re: [SQL] Best Fit SQL query statement

2007-08-10 Thread Fernando Hevia
ing the explain plan. It has ~31k rows. Any hindsight will be greatly appreciated. Regards, Fernando. -Mensaje original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] En nombre de hubert depesz lubaczewski Enviado el: Viernes, 10 de Agosto de 2007 05:00 Para: Kiran CC: pgsql-sql@postgresql.o

Re: [SQL] Best Fit SQL query statement

2007-08-10 Thread hubert depesz lubaczewski
On Mon, Aug 06, 2007 at 01:57:07AM -0700, Kiran wrote: > Could anyone help me in writing Best Fit SQL statement. > Suppose we have table t1 with coloumn t1 (text) with following rows. > 98456 > 98457 > 9845 > 9846 > 984 > 985 > 98 > 99 > and if I query on 98456 the result must be 98456, > However

[SQL] Best Fit SQL query statement

2007-08-09 Thread Kiran
All, Could anyone help me in writing Best Fit SQL statement. Suppose we have table t1 with coloumn t1 (text) with following rows. 98456 98457 9845 9846 984 985 98 99 and if I query on 98456 the result must be 98456, However if I query on 98455 the result must be 9845 and If I query 9849 the res

Re: [SQL] Best Fit SQL query statement

2007-08-06 Thread Rodrigo De León
On Aug 6, 3:57 am, Kiran <[EMAIL PROTECTED]> wrote: > and if I query on 98456 the result must be 98456, > However if I query on 98455 the result must be 9845 > and If I query 9849 the result must be 984 SELECT MAX(t1) FROM t1 WHERE '9849' LIKE t1 || '%'; ---(end of bro