Search Postgresql Archives

Re: Other queries locked out during long insert

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

 



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.

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[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