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.