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] foreign key pointing to diff schema?

2007-08-10 Thread gherzig
> On 8/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: >> Hi all. Can i make a FK who points a table in a different schema? Or >> this >> is implemented via a trigger by my own? > > Sure. just prefix the table name with the schemaname and a . > > create schema abc; > alter user me set search_p

Re: [SQL] foreign key pointing to diff schema?

2007-08-10 Thread Scott Marlowe
On 8/10/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > Hi all. Can i make a FK who points a table in a different schema? Or this > is implemented via a trigger by my own? Sure. just prefix the table name with the schemaname and a . create schema abc; alter user me set search_path='abc', 'pub

[SQL] foreign key pointing to diff schema?

2007-08-10 Thread gherzig
Hi all. Can i make a FK who points a table in a different schema? Or this is implemented via a trigger by my own? Thanks! Gerardo ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate subscribe-nomail

Re: [SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-10 Thread Tom Lane
Andreas Joseph Krogh <[EMAIL PROTECTED]> writes: > Is there a way I can have multiple columns in the ORDER BY clause, each with > different ASC/DESC-order and still use an index to speed up sorting? A btree index isn't magic, it's just an ordered list of entries. So you can't just randomly flip t

Re: [SQL] Race condition in resetting a sequence

2007-08-10 Thread Scott Marlowe
On 8/4/07, Lew <[EMAIL PROTECTED]> wrote: > Steve Midgley writes: > >> The code I provided to reset a primary key sequence is actually part of > >> Ruby on Rails core library - actually they use something very similar > >> to what I originally sent: > ... > >> SELECT setval('#{sequence}', (SELECT C

Re: [SQL] Best Fit SQL query statement

2007-08-10 Thread Fernando Hevia
Hi Depesz, I was curious about your solution for Best Fit since I had mine working in a function with a loop: ... FOR v_len IN REVERSE v_max..v_min LOOP v_prefix := substring(v_destino, 1, v_len); SELECT * INTO v_result FROM numeracion WHERE prefijo = v_prefix; IF FOUND

[SQL] Re: [NOVICE] Install two different versions of postgres which should run in parallel

2007-08-10 Thread Oliver Elphick
On Fri, 2007-08-10 at 14:33 +0300, Loredana Curugiu wrote: > Hi all, > > I need to have two different vesions of postgres running in parallel > on > different ports. Does anyone knows how to install two different > versions > of postgres (7.4.5 and 8.2.4) on the same computer? I am using Linux >

Re: [SQL] Install two different versions of postgres which should run in parallel

2007-08-10 Thread Scott Marlowe
On 8/10/07, Loredana Curugiu <[EMAIL PROTECTED]> wrote: > Hi all, > > I need to have two different vesions of postgres running in parallel on > different ports. Does anyone knows how to install two different versions > of postgres (7.4.5 and 8.2.4) on the same computer? I am using Linux > opera

Re: [SQL] Install two different versions of postgres which should run in parallel

2007-08-10 Thread Gerardo Herzig
Loredana Curugiu wrote: Hi all, I need to have two different vesions of postgres running in parallel on different ports. Does anyone knows how to install two different versions of postgres (7.4.5 and 8.2.4) on the same computer? I am using Linux operating system. Any information would greatly

[SQL] Index usage in order by with multiple columns in order-by-clause

2007-08-10 Thread Andreas Joseph Krogh
I have the following test-case: CREATE TABLE test( name varchar PRIMARY KEY, value varchar NOT NULL, created timestamp not null ); create index test_lowernamevalue_idx ON test ((lower(name) || lower(value))); create index test_lowernamevaluecreated_idx ON test ((lower(name) || lower(value)), cre

[SQL] Re: [NOVICE] Install two different versions of postgres which should run in parallel

2007-08-10 Thread Sean Davis
Loredana Curugiu wrote: > Hi all, > > I need to have two different vesions of postgres running in parallel on > different ports. Does anyone knows how to install two different versions > of postgres (7.4.5 and 8.2.4) on the same computer? I am using Linux > operating system. You can install from

[SQL] Install two different versions of postgres which should run in parallel

2007-08-10 Thread Loredana Curugiu
Hi all, I need to have two different vesions of postgres running in parallel on different ports. Does anyone knows how to install two different versions of postgres (7.4.5 and 8.2.4) on the same computer? I am using Linux operating system. Any information would greatly be appreciated. Loredana

[SQL] Join optimization

2007-08-10 Thread Pablo Barrón
Hi! I've been trying to optimize a query in which I join several tables, since I've seen it takes about 2 seconds, which is way too much. Well, the query is the following, I'm using LEFT OUTER JOIN just when the tables can have NULL results, plain JOIN otherwise: select ="select to_char(a.fecha_

Re: [SQL] Using function like where clause

2007-08-10 Thread hubert depesz lubaczewski
On Mon, Aug 06, 2007 at 04:44:29PM -0300, Ranieri Mazili wrote: > 1) Can I use a function that will return a string in a where clause like > bellow? > 2) Can I use a function that will return a string to return the list of > columns that I want to show like below? not in sql. you can in pl/pgsql

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