Search Postgresql Archives

Re: Other queries locked out during long insert

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>   http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while 
> boarding. Thank you for flying nlogn airlines.

Attachment: signature.asc
Description: Digital signature


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux