Re: Slow Bulk Delete

Поиск
Список
Период
Сортировка
От Pierre C
Тема Re: Slow Bulk Delete
Дата
Msg-id op.vcug7tj0eorkce@immo.peufeu.com
обсуждение исходный текст
Ответ на Slow Bulk Delete  (thilo <thilo.tanner@gmail.com>)
Ответы Re: Slow Bulk Delete  (Jon Nelson <jnelson+pgsql@jamponi.net>)
Список pgsql-performance
> DELETE FROM table1 WHERE table2_id = ?

For bulk deletes, try :

DELETE FROM table1 WHERE table2_id IN (list of a few thousands ids)

- or use a JOIN delete with a virtual VALUES table
- or fill a temp table with ids and use a JOIN DELETE

This will save cliet/server roundtrips.

Now, something that can make a DELETE very slow is a non-indexed ON DELETE
CASCADE foreign key : when you DELETE FROM table1 and it cascades to a
DELETE on table2, and you forget the index on table2. Also check the time
spent in triggers. Do you have a GIN index ?

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

Предыдущее
От: Piotr Legiecki
Дата:
Сообщение: Re: old server, new server, same performance
Следующее
От: Scott Marlowe
Дата:
Сообщение: Re: old server, new server, same performance