Gnanakumar, 03.02.2011 13:00:
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
Maybe this pattern would work for you: UPDATE my_table SET the_column = CASE WHEN some_id_column = 1 then 100 WHEN some_id_column = 2 then 200 WHEN some_id_column = 3 then 300 WHEN some_id_column = 4 then 400 WHEN some_id_column = 5 then 500 END WHERE some_id_column IN (1,2,3,4,5) But that get's pretty nasty if you have more than just those 5 rows. -- Sent via pgsql-admin mailing list (pgsql-admin@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-admin