Re: MERGE: performance advices - Mailing list pgsql-general

From Steve Clark
Subject Re: MERGE: performance advices
Date
Msg-id 48BD5750.2050906@netwolves.com
Whole thread Raw
In response to Re: MERGE: performance advices  ("Richard Broersma" <richard.broersma@gmail.com>)
Responses Re: MERGE: performance advices  ("Richard Broersma" <richard.broersma@gmail.com>)
List pgsql-general
Richard Broersma wrote:
> On Tue, Sep 2, 2008 at 4:19 AM, Ivan Sergio Borgonovo
> <mail@webthatworks.it> 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 JOIN d ON s.pk = d.pk
> WHERE d.pk IS NULL;
>
>
Hello Richard,

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 exists
        (select b.event_log_no from myevents b
         where a.event_status = 1 and a.event_ref_log_no IS NOT NULL
                and a.event_ref_log_no = b.event_log_no and a.event_log_no not in
                        (select event_log_no from myevents)
        )

Thanks,
Steve

pgsql-general by date:

Previous
From: Tony Caduto
Date:
Subject: Re: RAISE NOTICE format in pgAdmin
Next
From: Bram Kuijper
Date:
Subject: SQL equivalent to \dT