Re: Extremely Slow Cascade Delete Operation

Поиск
Список
Период
Сортировка
От Craig Ringer
Тема Re: Extremely Slow Cascade Delete Operation
Дата
Msg-id 4B4EB1DE.8000106@postnewspapers.com.au
обсуждение исходный текст
Ответ на Re: Extremely Slow Cascade Delete Operation  (Yan Cheng Cheok <yccheok@yahoo.com>)
Список pgsql-general
Yan Cheng Cheok wrote:

> I simply run a delete operation :
>
> delete from lot where lot_id = 3;
>
> It takes TWO hours and never able to return!

What does:

EXPLAIN DELETE FROM lot WHERE lot_id = 3;

report?

By the way, you've created a LOT of indexes. Indexes speed up lookups,
but can slow down insert/update/delete. They also use disk space. So
avoid creating indexes for things unless you know the index will
actually be used and be useful. Using EXPLAIN and EXPLAIN ANALYZE are
helpful for discovering this.

In general, I find creating indexes on foreign key columns to be a good
idea unless you never expect to DELETE from the parent table (say, if
you only TRUNCATE, if you rely on partitioning, or if the parent table
is append-only).

--
Craig Ringer

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

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: Collate order on Mac OS X, text with diacritics in UTF-8
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Collate order on Mac OS X, text with diacritics in UTF-8