Re: Other queries locked out during long insert

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Other queries locked out during long insert
Дата
Msg-id 20081217105354.GB7501@svana.org
обсуждение исходный текст
Ответ на Other queries locked out during long insert  ("Joshua J. Kugler" <joshua@eeinternet.com>)
Список pgsql-general
On Wed, Dec 17, 2008 at 01:18:04AM -0900, Joshua J. Kugler wrote:
> I've read the Pg docs about MVCC and possible locks that indexes can
> create.  Even so, I can't figure out why my code is causing all other
> queries to block while it is running.  I'm reading data in from a file
> (line by line, its CSV), doing a little pre-processing, and inserting
> it into a table.

Normal updates and inserts indeed use MVCC, but TRUNCATE does not. It
takes an exclusive lock. If you want to be able to continue doing
queries you need to do a DELETE nistead of TRUNCATE.

Another common trick is to load into another table and then rename it
into place.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.

Вложения

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

Предыдущее
От: Thomas Kellerer
Дата:
Сообщение: Re: A bit confused about Postgres Plus
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: Other queries locked out during long insert