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

From Peter Eisentraut
Subject Re: Other queries locked out during long insert
Date
Msg-id 200812171258.11586.peter_e@gmx.net
Whole thread Raw
In response to Other queries locked out during long insert  ("Joshua J. Kugler" <joshua@eeinternet.com>)
Responses Re: Other queries locked out during long insert  ("Joshua J. Kugler" <joshua@eeinternet.com>)
List pgsql-general
On Wednesday 17 December 2008 12:18:04 Joshua J. Kugler wrote:
> Begin
> Truncate table1, table2
>
> for row in file1:
>     insert into table1
>     sleep(0.001) # see note below
>
> for row in file2:
>     insert into table2
>     sleep(0.001) # see note below
>
> Commit

> During the time where the insert loops are running, I cannot do any
> queries against table1 and table2.

Because the TRUNCATE commands are taking out an exclusive lock on the tables.

> My understanding of MVCC is that I should be able to query against those
> tables while these insert loops are in their transaction.

You get the MVCC behavior if you use DELETE instead of TRUNCATE.  TRUNCATE is
specifically designed for better speed and less concurrency.  It's your
choice.

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Other queries locked out during long insert
Next
From: "Dave Page"
Date:
Subject: Re: A bit confused about Postgres Plus