Re: Replaceing records - Mailing list pgsql-general

From Ron Johnson
Subject Re: Replaceing records
Date
Msg-id 1062667466.17057.11.camel@haggis
Whole thread Raw
In response to Replaceing records  (Alex <alex@meerkatsoft.com>)
Responses Re: Replaceing records
List pgsql-general
On Thu, 2003-09-04 at 03:00, Alex wrote:
> Hi,
> MySQL has a nice feature that allows to call a replace rather insert
> which will attempt to insert if record not present and replace if it does.
>
> Is there any similar feature ?
>
> Currently I run a select prior to any insert and then update or insert
> depending on the result of the select. The problem here is that I just
> doubled the queries. Doing so on a table with 5Mio rows and on 100k
> inserts will take time and I would like to have an efficient way of
> doing it.

What if you try do the INSERT, and if it returns with a "key exists"
error, do the UPDATE?

Will the SELECT really slow things down that much, since the record
will be in buffers after you touch it the 1st time?

--
-----------------------------------------------------------------
Ron Johnson, Jr. ron.l.johnson@cox.net
Jefferson, LA USA

"All machines, no matter how complex, are considered to be based
on 6 simple elements: the lever, the pulley, the wheel and axle,
the screw, the wedge and the inclined plane."
Marilyn Vos Savant


pgsql-general by date:

Previous
From: "E. Zorn (RDG-rational) postsql"
Date:
Subject: WHERE boolean = true -> failure
Next
From: Paul Thomas
Date:
Subject: Re: Tomcat Connection Pool?