From: | Steve Clark <sclark(at)netwolves(dot)com> |
---|---|
To: | Richard Broersma <richard(dot)broersma(at)gmail(dot)com> |
Cc: | Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>, PostgreSQL <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: MERGE: performance advices |
Date: | 2008-09-02 15:10:08 |
Message-ID: | 48BD5750.2050906@netwolves.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Richard Broersma wrote:
> On Tue, Sep 2, 2008 at 4:19 AM, Ivan Sergio Borgonovo
> <mail(at)webthatworks(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Gobeille | 2008-09-02 15:25:50 | pg_catalog forward compatibility |
Previous Message | Tony Caduto | 2008-09-02 14:37:01 | Re: RAISE NOTICE format in pgAdmin |