Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Richard Broersma
On Tue, Sep 2, 2008 at 10:58 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Richard Broersma" <[EMAIL PROTECTED]> writes: >> There is one possible alteration that may or many not improve >> performance. This would be to replace the EXISTS with a LEFT JOIN >> WHERE IS NOT NULL; > > That changes the beh

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Steve Clark
Tom Lane wrote: "Richard Broersma" <[EMAIL PROTECTED]> writes: There is one possible alteration that may or many not improve performance. This would be to replace the EXISTS with a LEFT JOIN WHERE IS NOT NULL; That changes the behavior, doesn't it? Or is event_log_no a unique key for Myeve

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Tom Lane
"Richard Broersma" <[EMAIL PROTECTED]> writes: > There is one possible alteration that may or many not improve > performance. This would be to replace the EXISTS with a LEFT JOIN > WHERE IS NOT NULL; That changes the behavior, doesn't it? Or is event_log_no a unique key for Myevents? I think wh

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Steve Clark
Richard Broersma wrote: On Tue, Sep 2, 2008 at 9:47 AM, Steve Clark <[EMAIL PROTECTED]> wrote: srm2=# explain srm2-# INSERT INTO Myevents srm2-# SELECT * ERROR: INSERT has more expressions than target columns srm2=# explain srm2-# INSERT INTO Myevents srm2-# SELECT * ERROR:

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Richard Broersma
On Tue, Sep 2, 2008 at 9:47 AM, Steve Clark <[EMAIL PROTECTED]> wrote: > srm2=# explain > srm2-# INSERT INTO Myevents > srm2-# SELECT * > ERROR: INSERT has more expressions than target columns > srm2=# explain > srm2-# INSERT INTO Myevents > srm2-# SELECT * > ERROR: INSERT has more ex

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Steve Clark
Richard Broersma wrote: On Tue, Sep 2, 2008 at 8:10 AM, Steve Clark <[EMAIL PROTECTED]> wrote: Is there a way to do something similar with the following? I am an SQL noob and the following takes longer to run than is reasonable, on the order of hours. insert into myevents select * from t_unit

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Richard Broersma
On Tue, Sep 2, 2008 at 8:10 AM, Steve Clark <[EMAIL PROTECTED]> wrote: > Is there a way to do something similar with the following? I am an SQL noob > and the > following takes longer to run than is reasonable, on the order of hours. > > insert into myevents select * from t_unit_event_log a where

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Steve Clark
Richard Broersma wrote: On Tue, Sep 2, 2008 at 4:19 AM, Ivan Sergio Borgonovo <[EMAIL PROTECTED]> wrote: insert into d (pk, c1, c2, ...) select pk, c1, c2, c3 from s where s.pk not in (select pk from d); This insert statement might be faster: INSERT INTO d (pk, c1, c2, ... ) SELECT pk, c1

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Richard Broersma
On Tue, Sep 2, 2008 at 4:19 AM, Ivan Sergio Borgonovo <[EMAIL PROTECTED]> wrote: > insert into d (pk, c1, c2, ...) select pk, c1, c2, c3 from s > where s.pk not in (select pk from d); This insert statement might be faster: INSERT INTO d (pk, c1, c2, ... ) SELECT pk, c1, c2, ... FROM s LEFT J

Re: [GENERAL] MERGE: performance advices

2008-09-02 Thread Gregory Stark
Ivan Sergio Borgonovo <[EMAIL PROTECTED]> writes: > I need to merge 2 tables: > > update d set c1=s.c1, c2=s.c2... from s where d.pk=s.pk; > insert into d (pk, c1, c2, ...) select pk, c1, c2, c3 from s > where s.pk not in (select pk from d); you could try making the not in an exists. In release