Re: [SQL] Query becoming slower on adding a primary key

2004-06-02 Thread Rajesh Kumar Mallah
Tom Lane wrote: [EMAIL PROTECTED] writes: tradein_clients=# explain analyze select email_id ,email ,contact from t_a a join email_source f using(email_id) join email_subscriptions h using(email_id) where 1=1 and f.source_id =1 and h.sub_id = 3 ; Runs for Eve

[SQL] UNIQUE columnt depdening on other column???

2004-06-02 Thread Andrei Bintintan
Hi,   I have a problem.   Let's say I have the following table: CREATE TABLE rekl_element(id serial PRIMARY KEY,active boolean NOT NULL DEFAULT 'y',num int4 NOT NULL,text varchar(10)); Now I want that "num" column is "unique" but only for those columns that have active='y'. For the col

Re: [SQL] UNIQUE columnt depdening on other column???

2004-06-02 Thread Richard Huxton
Andrei Bintintan wrote: Hi, I have a problem. Let's say I have the following table: CREATE TABLE rekl_element( id serial PRIMARY KEY, active boolean NOT NULL DEFAULT 'y', num int4 NOT NULL, text varchar(10) ); Now I want that "num" column is "unique" but only for those columns that have activ

Re: [SQL] UNIQUE columnt depdening on other column???

2004-06-02 Thread Reinoud van Leeuwen
On Wed, Jun 02, 2004 at 02:39:45PM +0300, Andrei Bintintan wrote: > Hi, > > I have a problem. > > Let's say I have the following table: > CREATE TABLE rekl_element( > id serial PRIMARY KEY, > active boolean NOT NULL DEFAULT 'y', > num int4 NOT NULL, > text varchar(10) > ); > > Now I want that

Re: [SQL] assistance on self join pls

2004-06-02 Thread Rajesh Kumar Mallah
Dear Darren, Your question is not very clear to me. On what columns do you want to aggregate? suppose u want to aggregate on outsite and inside ip you shud group by those columns and run a aggregate function like sum or avg etc , suppose u want the total traffic for every pair you can do this: sele

[SQL] function with a composite type calling another function - Mission Impossible?

2004-06-02 Thread Riccardo G. Facchini
Hi. I'm trying to work a fairly complex set of functions that use a composite type for internal usage. This composite type should be passed to a specific function that takes care of some housekeeping actions... I haven't been able to make them work. as an example, I've generated a series of silly

Re: [SQL] function with a composite type calling another function - Mission Impossible?

2004-06-02 Thread Tom Lane
"Riccardo G. Facchini" <[EMAIL PROTECTED]> writes: > declare my_new_complex complex_number; > select * from complex_to_complex(my_new_complex) into my_result; > ERROR: column "my_new_complex" does not exist plpgsql doesn't presently cope with passing whole-row variables into SQL expressions, wh

Re: [SQL] function with a composite type calling another function - Mission Impossible?

2004-06-02 Thread Riccardo G. Facchini
--- Tom Lane <__> wrote: > "Riccardo G. Facchini" <__> writes: > > declare my_new_complex complex_number; > > > select * from complex_to_complex(my_new_complex) into my_result; > > > ERROR: column "my_new_complex" does not exist > > plpgsql doesn't presently cope with passing whole-row variable

Re: [SQL] Query becoming slower on adding a primary key

2004-06-02 Thread Rajesh Kumar Mallah
Even the first query used to run fine before but one fine day it changed plans i think. Regds Mallah. Rajesh Kumar Mallah wrote: Tom Lane wrote: [EMAIL PROTECTED] writes: tradein_clients=# explain analyze select email_id ,email ,contact from t_a a join email_source f using(email_id) join email