Re: INSERT OU UPDATE WITHOUT SELECT?

From: "Dave Dutcher" <dave(at)tridecap(dot)com>
To: "'PFC'" <lists(at)peufeu(dot)com>
Cc: <pgsql-performance(at)postgresql(dot)org>
Subject: Re: INSERT OU UPDATE WITHOUT SELECT?
Date: 2006-05-30 22:54:00
Message-ID: 039201c6843b$f11eeaf0$8300a8c0@tridecap.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

What I do when I'm feeling lazy is execute a delete statement and then
an insert. I only do it when I'm inserting/updating a very small number
of rows, so I've never worried if its optimal for performance. Besides
I've heard that an update in postgres is similar in performance to a
delete/insert.

> -----Original Message-----
> From: pgsql-performance-owner(at)postgresql(dot)org
> [mailto:pgsql-performance-owner(at)postgresql(dot)org] On Behalf Of PFC
> Sent: Tuesday, May 30, 2006 5:35 PM
> To: Jonah H. Harris; Waldomiro
> Cc: pgsql-performance(at)postgresql(dot)org
> Subject: Re: [PERFORM] INSERT OU UPDATE WITHOUT SELECT?
>
>
> > PostgreSQL does not support MERGE at the moment, sorry.
>
> Issue an UPDATE, and watch the rowcount ; if the
> rowcount is 0, issue an
> INSERT.
> Be prepared to retry if another transaction has
> inserted the row
> meanwhile, though.
>
> MERGE would be really useful.
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message D'Arcy J.M. Cain 2006-05-30 23:05:08 Re: INSERT OU UPDATE WITHOUT SELECT?
Previous Message Alvaro Herrera 2006-05-30 22:38:18 Re: INSERT OU UPDATE WITHOUT SELECT?