Re: Is there a batch/bulk UPDATE syntax available?

From: Keith Gabryelski <keith(at)fluentmobile(dot)com>
To: gnanam(at)zoniac(dot)com
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Is there a batch/bulk UPDATE syntax available?
Date: 2011-02-11 02:59:16
Message-ID: AANLkTi=Xy9Q7BXTy19EDbsG3YWEL46mS-FJ6VFLH+xfu@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)zoniac(dot)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
>
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Selva manickaraja 2011-02-11 04:43:10 Cascading Recovery
Previous Message Fabricio 2011-02-11 01:19:33 mapping libraries