Search Postgresql Archives

Re: MERGE: performance advices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Broersma wrote:
On Tue, Sep 2, 2008 at 4:19 AM, Ivan Sergio Borgonovo
<mail@xxxxxxxxxxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux