Re: COPY with fk's slow

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: COPY with fk's slow
Дата
Msg-id 12040.1044541862@sss.pgh.pa.us
обсуждение исходный текст
Ответ на COPY with fk's slow  (John Smith <john_smith_45678@yahoo.com>)
Ответы Re: COPY with fk's slow
Список pgsql-general
John Smith <john_smith_45678@yahoo.com> writes:
> I'm playing around with importing 10,000 records into a table with a single index and a single foreign key. COPY
takesroughly 10 minutes(!). However, if I drop the foreign key, COPY takes a couple seconds, THEN adding the foreign
keyback takes another few seconds. Any idea why COPY with a f/k takes so much longer? Any workarounds? Such as lock the
table,drop fk, copy, add fk, unlock? 

Sounds like you are getting a bad plan for the fk-checking query.  Are
the referencing and referenced columns exactly the same datatype?  Do
they both have indexes?

BTW, when experimenting with this, keep in mind that the backend caches
query plans for fk queries.  You'll typically need to start a fresh
connection after doing something that you hope will improve the plan.

            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: How do I create an array?
Следующее
От: Serkan Bektaþ
Дата:
Сообщение: FW: Webmin version 1.060 released