0

What is the default locking mechanism in PostgresSQL when we create a table ? is it row, page, table level or something else?

Is it possible to specify row level locking when we create a table ? something like below in Sybase.

CREATE TABLE user 
(...)
LOCK DATRAROWS  

Or do we not need to specify any locking strategy and leave it to Postgres to choose the best while we dealing CRUD ?

Cheers!

3
  • 1
    I believe postgres always uses the least intrusive locking mechanism possible -- MVCC row level locking, in most cases. Commented Apr 30, 2011 at 0:29
  • Why would you need to do that? Commented Apr 30, 2011 at 6:37
  • I'm coming from Sybase space, where we used to explicitly set lock datarows, and here in my specific use case, I don't want Postgres to use anything other than row level locking. Now I understand things are bit different in PGSql :-) Commented May 1, 2011 at 14:28

2 Answers 2

1

There isn't anything you can specify at CREATE TABLE time for PostgreSQL. At run time, you can select rows FOR UPDATE or FOR SHARE. If you're coming to PostgreSQL from another platform, you should skim the docs on concurrency control.

Sign up to request clarification or add additional context in comments.

Comments

1

There is no locking when you create a table. Locking can be read here: http://www.postgresql.org/docs/9.0/static/explicit-locking.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.