select locks table for updates

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

select locks table for updates

Yambu
Hi

Does a select lock tables for updates?
Reply | Threaded
Open this post in threaded view
|

RE: select locks table for updates

Michel SALAIS

No! Not in PostgreSQL.

However it is true for SQL Server.

 

Michel SALAIS

De : Yambu <[hidden email]>
Envoyé : jeudi 19 novembre 2020 11:07
À : Pgsql-admin <[hidden email]>
Objet : select locks table for updates

 

Hi

 

Does a select lock tables for updates?

Reply | Threaded
Open this post in threaded view
|

Re: select locks table for updates

Alexander Shelemin
That depends on transaction isolation level. By default sql server doesn't use MVCC, so selects need shared locks. It's easily changed, though. 

On Thu, 19 Nov 2020, 11:20 Michel SALAIS, <[hidden email]> wrote:

No! Not in PostgreSQL.

However it is true for SQL Server.

 

Michel SALAIS

De : Yambu <[hidden email]>
Envoyé : jeudi 19 novembre 2020 11:07
À : Pgsql-admin <[hidden email]>
Objet : select locks table for updates

 

Hi

 

Does a select lock tables for updates?

Reply | Threaded
Open this post in threaded view
|

Re: select locks table for updates

Simon Riggs
In reply to this post by Michel SALAIS
On Thu, 19 Nov 2020 at 10:20, Michel SALAIS <[hidden email]> wrote:
>
> No! Not in PostgreSQL.

In normal SELECTs, that is correct.

If you use SELECT ... FOR UPDATE then rows will be locked.

--
Simon Riggs                http://www.EnterpriseDB.com/


Reply | Threaded
Open this post in threaded view
|

RE: select locks table for updates

Michel SALAIS
I think the original question wasn't about what can be done. Any way that is how I considered it. A simple question, a simple reply taking into account default behavior only. The point was just to say that things don't go the same everywhere...

Michel SALAIS

-----Message d'origine-----
De : Simon Riggs <[hidden email]>
Envoyé : jeudi 19 novembre 2020 22:14
À : Michel SALAIS <[hidden email]>
Cc : Yambu <[hidden email]>; Pgsql-admin <[hidden email]>
Objet : Re: select locks table for updates

On Thu, 19 Nov 2020 at 10:20, Michel SALAIS <[hidden email]> wrote:
>
> No! Not in PostgreSQL.

In normal SELECTs, that is correct.

If you use SELECT ... FOR UPDATE then rows will be locked.

--
Simon Riggs                http://www.EnterpriseDB.com/