Re: MERGE: performance advices

From: "Richard Broersma" <richard(dot)broersma(at)gmail(dot)com>
To: "Ivan Sergio Borgonovo" <mail(at)webthatworks(dot)it>
Cc: PostgreSQL <pgsql-general(at)postgresql(dot)org>
Subject: Re: MERGE: performance advices
Date: 2008-09-02 12:38:45
Message-ID: 396486430809020538l3728ba9bm1d47674010ecbc31@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

--
Regards,
Richard Broersma Jr.

Visit the Los Angeles PostgreSQL Users Group (LAPUG)
http://pugs.postgresql.org/lapug

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tony Caduto 2008-09-02 14:37:01 Re: RAISE NOTICE format in pgAdmin
Previous Message Bram Kuijper 2008-09-02 12:26:55 SQL equivalent to \dT