slow update

Поиск
Список
Период
Сортировка
От Janning Vygen
Тема slow update
Дата
Msg-id 200207261314.g6QDEcM32601@janning.planwerk6.local
обсуждение исходный текст
Ответы Re: slow update  (Andrew Sullivan <andrew@libertyrms.info>)
Список pgsql-general
Hi,

i need to update a table in a database and i already managed it to
copy new data in a temproary table with 'copy' command very quick.

what i have is
CREATE TABLE tmp  (id int4, val1 int4, val2 int4);
CREATE TABLE real (id int4 PRIMARY KEY, val1 int4, val2 int4);

not all id s in real have appropiate values in temp.
now i just want to merge these tables and  i tried:

UPDATE real
   SET val1=(SELECT val1 FROM temp WHERE temp.id = real.id ),
       val2=(SELECT val2 FROM temp WHERE temp.id = real.id )
WHERE  id IN (SELECT temp.id FROM temp);

update is taking very long time. there is an index on real but not on
the columns which i update and theer are no triggers at all.
but there are many, many rows in real.

Can anybody give me a hint to a faster way updating the data??

it looks like a very easy task for the database just to merge to
tables, but maybe its not?

kind regards,
janning

В списке pgsql-general по дате отправления:

Предыдущее
От: "Christian H. Stork"
Дата:
Сообщение: Evolving databases (eg deleting columns)
Следующее
От: Elielson Fontanezi
Дата:
Сообщение: set DateStyle to 'SQL'