Re: Is there a batch/bulk UPDATE syntax available? - Mailing list pgsql-admin

From Keith Gabryelski
Subject Re: Is there a batch/bulk UPDATE syntax available?
Date
Msg-id AANLkTi=Xy9Q7BXTy19EDbsG3YWEL46mS-FJ6VFLH+xfu@mail.gmail.com
Whole thread Raw
In response to Is there a batch/bulk UPDATE syntax available?  ("Gnanakumar" <gnanam@zoniac.com>)
List pgsql-admin
create table tmp
(
  id serial not null primary key,
  name text,
  age integer
);

insert into tmp (name,age) values ('keith', 43),('leslie', 40),('bexley', 19),('casey', 6);

update tmp
 set age = data_table.age
from
(
  select 'keith'::text as name, 44::integer as age
 union
  select 'leslie', 50
 union
  select 'bexley', 10
 union
  select 'casey', 12
) as data_table
where
 tmp.name = data_table.name;


On Thu, Feb 3, 2011 at 7:00 AM, Gnanakumar <gnanam@zoniac.com> wrote:
> Hi,
>
> Is there a batch/bulk UPDATE query syntax available in PostgreSQL, similar
> to multirow VALUES syntax available for INSERT?
>
> INSERT Multirow VALUES syntax example:
> INSERT INTO films (code, title, did, date_prod, kind) VALUES
>    ('B6717', 'Tampopo', 110, '1985-02-10', 'Comedy'),
>    ('HG120', 'The Dinner Game', 140, DEFAULT, 'Comedy');
>
> There is a situation in my application, where I am performing lots and lots
> of updates on individual rows. I am trying to figure out how to make the
> updates faster.
>
> Any other ideas/ways to make updates faster are highly appreciated.
>
> Regards,
> Gnanam
>
>

pgsql-admin by date:

Previous
From: Fabricio
Date:
Subject: mapping libraries
Next
From: Selva manickaraja
Date:
Subject: Cascading Recovery