From: | Christophe Pettus <xof(at)thebuild(dot)com> |
---|---|
To: | John Lb <johnlb77(at)gmail(dot)com> |
Cc: | psycopg(at)postgresql(dot)org |
Subject: | Re: psycopg concurrency control |
Date: | 2016-09-12 22:48:26 |
Message-ID: | 56ECBEC2-B692-4EF8-99C4-70CF526C3675@thebuild.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | psycopg |
On Sep 12, 2016, at 3:43 PM, John Lb <johnlb77(at)gmail(dot)com> wrote:
> I did some more documentation reading and I noticed that I can use the LOCK command example : LOCK TABLE mytable IN ACCESS EXCLUSIVE MODE . Reason for ACCESS EXCLUSIVE is that there is tip in the documentation that says only ACCESS EXCLUSIVE can block a SELECT.
>
> Am I thinking right ??
You are correct in that is the only lock mode that will block a SELECT. Note that this means you will effectively have threads going single-file through the database, with very significant performance penalties.
You might consider using SELECT ... FOR UPDATE instead of a explicit table-level lock. This will prevent changes to the rows that the thread is working on, while not blocking SELECT ... FOR UPDATE against a different set of rows.
> Further a question : when doing this way , the Read Committed Isolation level can stay default ??
Yes, because there is effectively no concurrency in the database, now.
--
-- Christophe Pettus
xof(at)thebuild(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | John Lb | 2016-09-13 00:00:29 | Re: psycopg concurrency control |
Previous Message | John Lb | 2016-09-12 22:43:28 | Re: psycopg concurrency control |