Re: Other queries locked out during long insert - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Other queries locked out during long insert
Date
Msg-id 20081217105354.GB7501@svana.org
Whole thread Raw
In response to Other queries locked out during long insert  ("Joshua J. Kugler" <joshua@eeinternet.com>)
List 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.

Attachment

pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: Re: A bit confused about Postgres Plus
Next
From: Peter Eisentraut
Date:
Subject: Re: Other queries locked out during long insert