Re: COPY FROM and TABLE LOCK question

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: COPY FROM and TABLE LOCK question
Дата
Msg-id 10611.1014867684@sss.pgh.pa.us
обсуждение исходный текст
Ответ на COPY FROM and TABLE LOCK question  (Benjamin Franks <benjamin@dzhan.com>)
Список pgsql-general
Benjamin Franks <benjamin@dzhan.com> writes:
> does the copy from command do an exclusive access lock on the table it is
> writing to?

Certainly not.  It gets the same kind of lock as INSERT does, viz
RowExclusiveLock.

> i'd like to do the following:
> --delete all rows from the table
> --drop table indexes
> --copy from the file to the table
> --recreate indexes

> however, i don't want other applications to try to select, insert, or
> update information from the table while the COPY FROM command is
> executing.

You will want to grab an explicit lock on the table.  Generally, PG's
philosophy is to get the weakest allowable lock on a table.  If you
want a stronger lock, you can grab it via a LOCK command before doing
whatever you want to do.

Dropping indexes requires an exclusive lock, so if you insist on the
above recipe then nothing less than exclusive lock will do.

            regards, tom lane

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

Предыдущее
От: Frank Bax
Дата:
Сообщение: Re: About vacuuming
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: sort mem size