| От | PFC |
|---|---|
| Тема | Re: Delete operation VERY slow... |
| Дата | |
| Msg-id | op.ta8kk1aqcigqcu@apollo13 обсуждение исходный текст |
| Ответ на | Re: Delete operation VERY slow... (David Leangen <postgres@leangen.net>) |
| Список | pgsql-performance |
> Wow! That was almost instantaneous. I can't believe the difference.
>
> The only inconvenience is that I need to remove all the foreign key
> constraints before truncating, then put them back after. But I suppose
> it is a small price to pay for this incredible optimization.
In that case, your DELETE might have been slowed down by foreign key
checks.
Suppose you have tables A and B, and table A has a column "b_id
REFERENCES B(id)"
When you delete from B postgres has to lookup in A which rows reference
the deleted rows in order to do the ON DELETE action you specified in the
constraint.
If you do not have an index on b_id, this can be quite slow... so you
should check if your foreign key relations that need indexes have them.
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера