Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm fairly new to postgresql. I've checked out the documentation and I can't find anything about how to do page-level locking.

I understand that I can set a table into a locking mode like this: LOCK TABLE myTable IN LOCKMODE ROW EXCLUSIVE;

How would I implement page level locking for my session? Let me know if it seems that I have a misunderstanding of the fundamentals.

share|improve this question
1  
PostgreSQL doesn't have page level locking. –  Frank Heikens Dec 1 '12 at 21:39

1 Answer 1

Why would you want to do explicit page level locking? You don't control what is on each page, so you'd be locking some arbitrary collection of data. What purpose would that serve?

I think you're looking for row-level locking, which is accomplished using SELECT ... FOR UPDATE or SELECT ... FOR SHARE.

PostgreSQL upgrades row-level locks to page-level locks internally in a few places like serializable snapshot predicate tracking, buffer management, etc. It'll do this when there are too many row level locks and they're becoming a performance issue. You don't need to care about this, as this will have almost no effect on you at the SQL level. Normal row locks - as acquired by UPDATE, DELETE, SELECT ... FOR UPDATE, SELECT ... FOR SHARE etc - are AFAIK never upgraded to page-level locks, as doing so would increase the probability of deadlocks.

If you're really convinced you want page-level locking, please explain what problem you're trying to solve in more detail and why row-level or table-level locking don't do the job.

See:

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.