Re: Adding a foreign key constraint is extremely slow
В списке pgsql-performance по дате отправления:
| От | Greg Stark |
|---|---|
| Тема | Re: Adding a foreign key constraint is extremely slow |
| Дата | |
| Msg-id | 874r5qmctw.fsf@stark.dyndns.tv обсуждение |
| Ответ на | Adding a foreign key constraint is extremely slow (bsamwel@xs4all.nl) |
| Ответы |
Re: Adding a foreign key constraint is extremely slow
|
| Список | pgsql-performance |
bsamwel@xs4all.nl writes: > alter table triples add foreign key(id1) references wwwlog(id); > > PostgreSQL starts doing heavy work for at least one and a half hour, and I > broke it off at that. It is not possible to "explain" a statement like > this! Probably what it does is that it will check the foreign key > constraint for every field in the table. This will make it completely > impossible to load my data, because: > > (2) I cannot set the foreign key constraints AFTER loading the 0.9 million > records because I've got no clue at all how long this operation is going > to take. Try adding an index on wwwlog(id) so that it can check the constraint without doing a full table scan for each value being checked. -- greg
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера