Batch Insert Performance

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Batch Insert Performance
Дата
Msg-id 87ptry3knr.fsf@stark.dyndns.tv
обсуждение исходный текст
Ответы Re: Batch Insert Performance  ("Peter Alberer" <h9351252@obelix.wu-wien.ac.at>)
Список pgsql-general
I'm trying to seed a database and I'm surprised by how slow it is. I'm doing a
query like:

 INSERT INTO source_other_xref (source_id, other_id) (
   SELECT source_id,1+trunc(1000*random())
     FROM source_table
   );

where source_table has 271,000 records. Table source_other_xref has two
columns both of which are foreign key references, one to source_table and the
other to another table.

It's been running for hours and hours.

The machine doesn't seem to be thrashing its disk writing or reading much. It
seems to be completely cpu-bound.

I'm thinking it's mostly wasting time checking the foreign key constraint. Is
there any equivalent to Oracle's ability to "disable" a constraint and then
reenable it later?

Even with the foreign key constraints I wouldn't have expected inserting 200k
records to take this long.

--
greg

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

Предыдущее
От: Greg Stark
Дата:
Сообщение: Re: Regarding select distinct ...query
Следующее
От: "Ian Harding"
Дата:
Сообщение: Re: Regarding select distinct ...query