Обсуждение: select locks table for updates

Поиск
Список
Период
Сортировка

select locks table for updates

От
Yambu
Дата:
Hi

Does a select lock tables for updates?

RE: select locks table for updates

От
"Michel SALAIS"
Дата:

No! Not in PostgreSQL.

However it is true for SQL Server.

 

Michel SALAIS

De : Yambu <hyambu@gmail.com>
Envoyé : jeudi 19 novembre 2020 11:07
À : Pgsql-admin <pgsql-admin@lists.postgresql.org>
Objet : select locks table for updates

 

Hi

 

Does a select lock tables for updates?

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, <msalais@msym.fr> wrote:

No! Not in PostgreSQL.

However it is true for SQL Server.

 

Michel SALAIS

De : Yambu <hyambu@gmail.com>
Envoyé : jeudi 19 novembre 2020 11:07
À : Pgsql-admin <pgsql-admin@lists.postgresql.org>
Objet : select locks table for updates

 

Hi

 

Does a select lock tables for updates?

Re: select locks table for updates

От
Simon Riggs
Дата:
On Thu, 19 Nov 2020 at 10:20, Michel SALAIS <msalais@msym.fr> 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/



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
simplereply 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 <simon@2ndquadrant.com>
Envoyé : jeudi 19 novembre 2020 22:14
À : Michel SALAIS <msalais@msym.fr>
Cc : Yambu <hyambu@gmail.com>; Pgsql-admin <pgsql-admin@lists.postgresql.org>
Objet : Re: select locks table for updates

On Thu, 19 Nov 2020 at 10:20, Michel SALAIS <msalais@msym.fr> 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/